Jenkins搭建Gitlab持续集成
公司内部博客通过Jekyll编写,并存储在内部gitlab服务器上。通过持续集成,可以实现博客的实时更新。
但是gitlab-ci项目首次安装遇到奇怪Bug,在公司搬迁后,又出现了通信问题;加上其难以Debug,决定使用替代方案Jenkins。
1 Jenkins Install
CentOS 7
1.1 Repo file
add repo file under
/etc/yum.repos.d/
[jenkins]
name=Jenkins
baseurl=http://pkg.jenkins.io/redhat
gpgcheck=0
1.2 Install
yum update
yum install jenkins
2 Jenkins Config
find jenkins config file rpm -ql jenkins
, normally, you can see /etc/sysconfig/jenkins
edit /etc/sysconfig/jenkins
file. e.g. JENKINS_PORT
for which port jenkins is listening.
3 Startup
service jenkins start/stop/restart
3.1 Explain
service
run System V init scripts, which are under /etc/init.d/
.
We can also use systemctl
difference between service and systemctl
4 Setup Process
4.1 Admin
- Create
new item
with name Blog-{name} - Send
GitLab CI Service URL
andSecret Token
under Build Triggers to User - generate
ssh key pair
& sendpublic key
to User.
ssh-keygen -t rsa -f ~/Documents/sshkey/{name}
4.2 User
- Fork Blog Template
- Add
ssh public key
to account - Add
webhook
underIntegration
of this project; - Generate
Gitlab Access Token
; sendproject git url
&Access Token
to Admin
4.3 Admin
- Create
Configure System
->Gitlab Connection
using UserAccess Token
with name Gitlab-API-Token-{username} - Complete
new item
configuration usingssh private key
with name sshKey-{username}.