Jenkins安裝配置
1.安裝
卸載自帶的git(CentOS6.5自帶的git版本是1.7.1 )
yum remove git
下載編譯安裝
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
yum install jenkins
啟動/停止(默認端口是8080)
service jenkins start/stop/restart
參考:https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions
2.maven集成
在jenkins的服務(wù)器上下載解壓好maven 包,然后在系統(tǒng)管理->Global Tool Configuration->
Global Tool Configuration中設(shè)置maven的home,如圖

3.git集成
安裝git,centos 默認安裝了1.7版本的git,首先要卸載掉,然后在安裝,安裝完成后git相關(guān)的命令默認在
/usr/local/git/bin/git
yum remove git
wget https://github.com/git/git/archive/v2.9.2.tar.gz
tar zxvf v2.9.2.tar.gz
cd git-2.9.2
make configure
./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
make all doc
make install install-doc install-html
配置git_home:
系統(tǒng)管理->Global Tool Configuration->
Global Tool Configuration中設(shè)置git的home,如圖

參考: http://www.yingzinanfei.com/2016/09/22/centos-anzhuanggaobanbengit/
4. gitlab的集成
在Jenkins安裝的服務(wù)器上, 創(chuàng)建一對rsa key, 在~/.ssh 生成一對密鑰 id_rsa id_rsa.pub
ssh-keygen -t rsa -C "username@qq.com"
# 一路回車, 默認路徑和文件名, 不要密碼
cd ~/.ssh
將公鑰id_rsa.pub 配置到 gitlab服務(wù)器中

將私鑰配置jenkins 服務(wù)器中



username 填寫 創(chuàng)建密鑰對的username,key填寫 id_rsa內(nèi)容
5創(chuàng)建一個自動構(gòu)建的job (gitlab maven tomcat)
選擇maven 項目

Credentials 選擇之前配置的私鑰

goals 填寫maven 的指令

構(gòu)建完成后需要部署到tomcat中,tomcat的用戶密碼必須在tomcat的tomcat-users配置好
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status"/>

至此 一個maven的自動構(gòu)建完成。