gitlab和jenkins

[root@server1 ~]# yum install -y policycoreutils-python openssh-server
[root@server1 ~]# yum install -y net-tools

2.启动postfix 和sshd 服务

[root@server1 ~]# systemctl start sshd
[root@server1 ~]# systemctl start  postfix

3.安装gitlab

[root@server1 ~]# rpm -ivh gitlab-ce-11.2.0-ce.0.el7.x86_64.rpm 

这里写图片描述
4.配置GitLab

[root@server1 ~]# vim /etc/gitlab/gitlab.rb

这里写图片描述
5.重置并启动操作

[root@server1 ~]# gitlab-ctl reconfigure

这里写图片描述

[root@server1 ~]# gitlab-ctl restart    #重启

这里写图片描述

访问Gitab页面输入:http://172.25.40.11
这里写图片描述
这里写图片描述

创建项目
这里写图片描述
这里写图片描述
这里写图片描述

添加公钥

[root@foundation40 ~]# cd .ssh
[root@foundation40 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@foundation40 .ssh]# cat id_rsa.pub

这里写图片描述

[root@foundation40 ~]# git clone [email protected]:root/demo.git

这里写图片描述


搭建Jenkins

1.安装JDK

[root@server1 ~]# rpm -ivh jdk-8u171-linux-x64.rpm 

2.安装jenkins

[root@server2 ~]# rpm -ivh jenkins-2.121.3-1.1.noarch.rpm 

3.开启jenkins,查看端口

[root@server2 ~]# /etc/init.d/jenkins start
[root@server2 ~]# netstat -antlp |grep :8080
tcp6       0      0 :::8080                 :::*                    LISTEN      2213/java           

4.设置网络(让虚拟机联网)

在物理机上添加网段
[root@foundation40 ~]# iptables -t nat -I POSTROUTING -s 172.25.40.0/24 -j MASQUERADE

[root@server2 ~]# route add default gw 172.25.40.250
[root@server2 ~]# vim /etc/resolv.conf 
nameserver 114.114.114.114 
[root@server2 ~]# ping  baidu.com
#ping一下百度,看网通不通

5.获得解锁 Jenkins密码

[root@server2 ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
372f6c9313f3472db55f19c81f85252a
将密码复制到网页,解锁Jenkins

网页访问http://172.25.68.11:8080

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述


整合

查看私钥

[root@server2 ~]# yun install -y git
[root@foundation40 ~]# cd .ssh
[root@foundation40 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@foundation40 .ssh]# cat id_rsa 

这里写图片描述

这里写图片描述
这里写图片描述
这里写图片描述

测试:

[root@foundation40 .ssh]# cd
[root@foundation40 ~]# cd demo/
[root@foundation40 demo]# ls
README.md
[root@foundation40 demo]# vim test.txt
[root@foundation40 demo]# cat test.txt 
hello world
[root@foundation40 demo]# git add test.txt
[root@foundation40 demo]# git  commit -m "add test.txt"
[root@foundation40 demo]# git push origin master

这里写图片描述
这里写图片描述
这里写图片描述

在jenkins下载插件
这里写图片描述
这里写图片描述
这里写图片描述


在Jenkins
这里写图片描述
这里写图片描述

在gitlab
这里写图片描述
生成token
这里写图片描述

修改gitlab参数

[root@server2 ~]# curl -X PUT --header "PRIVATE-TOKEN:Gkji7zJ_AxbZYxU6CQ_G" 'http://172.25.40.11/api/v4/application/settings?allow_local_requests_from_hooks_and_services=true'

在gitlab上
这里写图片描述
这里写图片描述

[root@foundation40 demo]# vim hello.txt
[root@foundation40 demo]# cat hello.txt 
hello world
hello world
[root@foundation40 demo]# git add hello.txt
[root@foundation40 demo]# git status -s
A  hello.txt
[root@foundation40 demo]# git commit -m "add hello.txt"
[root@foundation40 demo]# git push origin master 

这里写图片描述

这里写图片描述
这里写图片描述

猜你喜欢

转载自blog.csdn.net/Argued_D/article/details/82015986