1)gitlab+jenkins自动化发布;gitlab搭建

                             安装gitlab

 

 

 

参考文档:

https://www.yiibai.com/gitlab/gitlab_introduction.html

 

 

1、下载epel

 wget http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm

2wget -O /etc/yum.repos.d/CentOS-Base.repo

3、关闭防火墙和seLinux

4 yum install curl policycoreutils openssh-server openssh-clients postfix -y

5、由于网络问题使用清华大学的镜像源

cat /etc/yum.repos.d/gitlab-ce.repo

[gitlab-ce]

name=gitlab-ce

baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7

repo_gpgcheck=0

gpgcheck=0

enabled=1

gpgkey=https://packages.gitlab.com/gpg.ke

 

6yum makecache

yum install -y gitlab-ce

 yum install -y git

7、配置并启动gitlab-ce

gitlab-ctl reconfigure

8、查看状态

 图片1.png

9、设置密码至少8位那就是12345678;用户root

 图片2.png


10、创建一个组

图片3.png 

 

 图片4.png


 图片5.png

11、创建一个项目

 图片6.png

 图片7.png

 

图片8.png

这里的路径需要去配置文件中修改:

 图片9.png

 图片10.png

之后启动生效。

创建完成之后它提示我们可以创建一个key对它进行管理

我们点击上面的README然后我们随便在里面写点东西 

 图片11.png

image.png

创建ssh免秘钥登陆 模拟使用gitlab这台服务器当做客户端

ssh-keygen -t rsa -C “你的邮箱”回三次车,密码为空


图片12.png

然后将密钥传到gitlab上面:

图片13.png

图片14.png


添加完之后我们就可以使用用户,就可以拉了 

这里需要做dns我们就在/etc/hosts/中修改

image.png

测试一下:

image.png

我们上传一个代码文件试试,一回发布到tomcat服务器上:这里已经上传了,但是简单说一下就行:这里吧index.html改成了server.xml

创建一个index.html用来模拟开发写代码并提交

[root@node1 test]# pwd

/test/test

[root@node1 test]# cat index.html

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

</head>

<body>

<h1>测试</h1>

</body>

</html>

[root@node1 test]# git add *    ##提交所有更改信息(删除 增加文件)

[root@node1 test]# git config --global user.email "******@163.com"   ##身份验证

[root@node1 test]# git config --global user.name "root"             ##身份验证

[root@node1 test]# git commit -m "add index.html"         ##

[master 1cdcea5] add index.html

 1 file changed, 10 insertions(+)

 create mode 100644 index.html

[root@node1 test]# git push origin master

Counting objects: 4, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (3/3), done.

Writing objects: 100% (3/3), 382 bytes | 0 bytes/s, done.

Total 3 (delta 0), reused 0 (delta 0)

To [email protected]:root/test.git

   5b44e15..1cdcea5  master -> master

验证查看gitlab上是否有提交的index.html

image.png


猜你喜欢

转载自blog.51cto.com/xiaorenwutest/2139031