ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Gitlab安装+jenkins安装

2022-01-12 18:01:56  阅读:113  来源: 互联网

标签:git python root Gitlab gitlab jenkins 安装 localhost


Jenkins

Jenkins本身是不具备任何功能的,Jenkins中所有的功能全部来自于插件。

1、为什么使用Jenkins

dev     开发环境
test 测试环境
pre 预发布环境
master 生成环境

2、Jenkins + GitLab

Jenkins 负责部署
GitLab 负责存放代码

3、Jenkins安装

1、yum
2、rpm
https://pkg.jenkins.io/redhat-stable/ #国外的网站无法下载查看清华大学开源镜像站
下载拉到本地:https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/

# Jenkins 是使用 Java 开发的
[root@localhost ~]# yum install java-1.8.0-openjdk* -y
[root@localhost ~]# yum install jenkins-2.249.1-1.1.noarch.rpm
#开启jenkins并查看
[root@jenkins ~]# systemctl start jenkins
[root@jenkins ~]# systemctl status jenkins.service
[root@jenkins ~]# netstat -nutlp
tcp6       0      0 :::8080                 :::*                   LISTEN      34983/java
此时可访问192.168.15.9:8080
根据提示复制如下密码:[root@jenkins ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
81c19573b71148a388c431254fe87824

4、安装Jenkins插件

[root@jenkins ~]# tar -tf plugins.tar.gz
[root@jenkins ~]# cd /var/lib/jenkins/plugins/
[root@localhost ~]# mv plugins.tar.gz /var/lib/jenkins/plugins/
[root@jenkins plugins]# tar -tf plugins.tar.gz
[root@jenkins plugins]# ll
[root@localhost plugins]# systemctl restart jenkins
#修改站点为国内下载地址:升级站点
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

#换源
[root@localhost updates]# cd /var/lib/jenkins/updates
[root@jenkins updates]# cat default.json
[root@localhost updates]# sed -i 's/https:\/\/updates.jenkins.io\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json
[root@localhost updates]# sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json

5、部署GitLab

 

代码管理    git     gitlab

常用的代码管理工具:GitHub、Gitee、GitLab

1、安装依赖
yum -y install policycoreutils openssh-server openssh-clients postfix

2、关闭防火墙,关闭selinux
systemctl disable firewalld

3、下载Gitlab安装包
[root@localhost ~]# curl -o gitlab-ce-13.9.7-ce.0.el7.x86_64.rpm https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.9.7-ce.0.el7.x86_64.rpm

4、安装gitlab
[root@localhost ~]# yum install gitlab-ce-13.9.7-ce.0.el7.x86_64.rpm -y

5、配置
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.11.8'  
nginx['listen_port'] = 80

# 刷新配置(默认启动)
[root@sean ~]# gitlab-ctl reconfigure
# 启动
[root@sean ~]# gitlab-ctl start
# 停止
[root@sean ~]# gitlab-ctl stop
# 重启
[root@sean ~]# gitlab-ctl restart

登录:192.168.15.8 输入用户名:root 密码:adminadmin登录成功即为成功

6、Git

 

 

1、初始化仓库
[root@localhost ~]# mkdir python
[root@localhost ~]# cd python/
[root@localhost python]# git init
Initialized empty Git repository in /root/python/.git/
[root@localhost python]# ll -a
total 0
drwxr-xr-x. 3 root root  18 Jan 12 11:41 .
dr-xr-x---. 5 root root 221 Jan 12 11:41 ..
drwxr-xr-x. 7 root root 119 Jan 12 11:41 .git


2、创建文件并加入缓存区
[root@localhost python]# vim index.py
[root@localhost python]# ll
total 4
-rw-r--r--. 1 root root 21 Jan 12 11:42 index.py
[root@localhost python]# git add index.py

[root@localhost python]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
# new file:   index.py
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# demo.py

3、提交至暂存区
git commit -m 'init'

4、提交至远程

# 创建仓库
# 添加用户名和邮箱
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"

# 管理远程仓库
git remote add origin http://192.168.11.8/root/python.git

# 提交至远程仓库
git push origin master

6.1、免密上传

 

 

# 关联SSH连接
[root@localhost python]# vim .git/config
#先删除下面的内容
[remote "origin"]
      url = git@192.168.11.8:root/python.git
      fetch = +refs/heads/*:refs/remotes/origin/*
[root@localhost python]# git remote add origin git@192.168.11.8:root/python.git
[root@localhost python]# ssh-keygen
# 将ssh 公钥上传至gitlab(右上角administrator——preferences——ssh key)

6.2、分支

# 查看本地分支
[root@localhost python]# git branch
* master

# 查看远程分支
[root@localhost python]# git branch -a
* master
remotes/origin/master

# 创建分支
[root@localhost python]# git checkout -b test
Switched to a new branch 'test'

# 将本地新创建的分支提交至远程
[root@localhost python]# git push origin test

# 切换分支
[root@localhost python]# git checkout master

6.3、Git Tag

git tag是一个特殊的分支,这个分支只允许创建和删除不允许修改。
[root@localhost python]# git tag -a stable-v1 -m '简介'
[root@localhost python]# git tag
stable-v1

6.4、创建一个代码仓库,将代码传输至远程仓库

7、Gitlab的使用

1.管理中心-设置-设置不允许注册
2.群组:创建用户,创建组
3.特殊条款

 

7.1、创建用户及用户组

1.Guest:可以创建issue、发表评论,不能读写版本库 
2.Reporter:可以克隆代码,不能提交,QA、PM 可以赋予这个权限
3.Developer:可以克隆代码、开发、提交、push,普通开发可以赋予这个权限
4.Maintainer:可以创建项目、添加tag、保护分支、添加项目成员、编辑项目,核心开发可以赋予这个 权限
5.Owner:可以设置项目访问权限 - Visibility Level、删除项目、迁移项目、管理组成员,开发组组 长可以赋予这个权限

7.2、使用Jenkins部署Django框架

 

标签:git,python,root,Gitlab,gitlab,jenkins,安装,localhost
来源: https://www.cnblogs.com/Haier123/p/15793698.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有