码迷,mamicode.com
首页 > Web开发 > 详细

gitlab+jenkins+webhook 代码发布

时间:2018-11-18 11:26:44      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:int   连接   word   bsp   restart   git clone   ica   wan   res   

https://docs.gitlab.com/omnibus/docker/ 官方参考文档

 

root@iZm5e68cj7e7kx71atc98eZ:~# sudo docker pull gitlab/gitlab-ce:latest

latest: Pulling from gitlab/gitlab-ce

18d680d61657: Pull complete

0addb6fece63: Pull complete

78e58219b215: Pull complete

eb6959a66df2: Pull complete

8f56c4bb1d27: Pull complete

6145e9d33b6a: Pull complete

70f6a2fb2280: Pull complete

e6c8215808aa: Pull complete

df7e9faf62df: Pull complete

87f06c1e794b: Pull complete

root@iZm5e68cj7e7kx71atc98eZ:/var/gitlab# mkdir config

root@iZm5e68cj7e7kx71atc98eZ:/var/gitlab# mkdir logs

root@iZm5e68cj7e7kx71atc98eZ:/var/gitlab# mkdir data

root@iZm5e68cj7e7kx71atc98eZ:/var/gitlab# sudo docker run --detach \

> --hostname gitlab \  可以设置成Ip 和下载地址有关

> --publish 8443:443 --publish 8888:80 --publish 2222:22 \

> --name gitlab \

> --restart always \

> --volume /var/gitlab/config:/etc/gitlab \

> --volume /var/gitlab/logs:/var/log/gitlab \

> --volume /var/gitlab/data:/var/opt/gitlab \

> gitlab/gitlab-ce:latest

cb04f1726e3a6a1cd94a7d63438cff6c13c16900a47a566d7fc4a099f4abfd46

技术分享图片

添加组成员

技术分享图片

创建用户

技术分享图片

技术分享图片

 

邮件设置

root@gitlab:/#cat /etc/gitlab/gitlab.rb

gitlab_rails[‘smtp_enable‘] = true

gitlab_rails[‘smtp_address‘] = "smtp.sina.com"

gitlab_rails[‘smtp_port‘] = 587

gitlab_rails[‘smtp_user_name‘] = "houpj@sina.com"

gitlab_rails[‘smtp_password‘] = "123456"

gitlab_rails[‘smtp_domain‘] = "sina.com"

gitlab_rails[‘smtp_authentication‘] = "login"

gitlab_rails[‘smtp_enable_starttls_auto‘] = true

gitlab_rails[‘smtp_tls‘] = false

gitlab_rails[‘gitlab_email_from‘] = ‘houpj@sina.com‘

修改权限

技术分享图片

 

组内添加项目

技术分享图片

技术分享图片

设置ssh密钥用来git clone 项目

root@iZm5e68cj7e7kx71atc98eZ:~/.ssh# ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:62VhUNby9iIC7q66f3VxzY6l4XgRay7A1SPlocdQomo root@iZm5e68cj7e7kx71atc98eZ

The key‘s randomart image is:

+---[RSA 2048]----+

|          ==+    |

|         ++*=.   |

|       .o..++*   |

|      ..o...O +  |

|     .E.S.oO O   |

|     .. oo=.B o  |

|     . ..oo+ .   |

|      o. o       |

|  o+o+. .        |

+----[SHA256]-----+

root@iZm5e68cj7e7kx71atc98eZ:~/.ssh# ls

authorized_keys  id_rsa  id_rsa.pub  known_hosts

root@iZm5e68cj7e7kx71atc98eZ:~/.ssh# chattr -i authorized_keys

root@iZm5e68cj7e7kx71atc98eZ:~/.ssh# cat id_rsa.pub >> authorized_keys

复制公钥到gitlab

root@iZm5e68cj7e7kx71atc98eZ:~/.ssh# cat id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDpFtcntTkCM5KjIe3ChsUJ7M2wvExQasKokFxnc/bPcNrYMJ+UtTQFA3wiHdPN892BCqzv1rHEC4oUcW4W7SVzZouzS1dxfMQzM+Z0CB0YBVn2g8QWVJxJXuW7bCWEB8OICew/UyitftZbzevGUMXwJUXLtIZOlhtloHkeEWTonUu5xU1uwZ59gIT3HPaL/0Mo0uVZtP1MP1jG6G5qvLGXX/3PPScnKDJQ7cmbsLKnEpJ0PQJkpE4woqWWIALDmHzPbOF1ubB6Auo4vRCNWO+dNwSU7dwZjfwAqhTFvSUZ/G9dW4PvN6153nGgvKY2N41gktiizJRPXpPMy/WtpMTz root@iZm5e68cj7e7kx71atc98eZ

技术分享图片

技术分享图片

 

默认的url不能使用

技术分享图片

修改克隆url

root@gitlab:/# cat /etc/gitlab/gitlab.rb

### GitLab Shell settings for GitLab

gitlab_rails[‘gitlab_shell_ssh_port‘] = 2222

# gitlab_rails[‘gitlab_shell_git_timeout‘] = 800

 

ssh://git@gitlab:2222/devops/devops_test.git

gitlab换成公网ip

ssh://git@123.123.123.123:2222/devops/devops_test.git

 

root@iZm5e68cj7e7kx71atc98eZ:~# git clone ssh://git@123.123.123.123:2222/devops/devops_test.git

Cloning into ‘devops_test‘...

The authenticity of host ‘[123.123.123.123]:2222 ([123.123.123.123]:2222)‘ can‘t be established.

ECDSA key fingerprint is SHA256:eQmb5j6h8fPc0efCAo/dlfCfnhLc9QRblNldRJPceaU.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘[123.123.123.123]:2222‘ (ECDSA) to the list of known hosts.

remote: Enumerating objects: 3, done.

remote: Counting objects: 100% (3/3), done.

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

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

Checking connectivity... done.

jenkins安装插件

技术分享图片

 

jenkins通过gitlab用户连接

技术分享图片

技术分享图片

 

Webhook设置

技术分享图片

技术分享图片

在gitlab里填写jenkins配置

技术分享图片

 

测试配置

技术分享图片

jenkins构建成功

技术分享图片

 

gitlab+jenkins+webhook 代码发布

标签:int   连接   word   bsp   restart   git clone   ica   wan   res   

原文地址:https://www.cnblogs.com/Honeycomb/p/9977105.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!