美文网首页
Jenkins安装配置

Jenkins安装配置

作者: 哥别打脸 | 来源:发表于2017-07-06 15:50 被阅读67次

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的服务器上下载解压好maven 包,然后在系统管理->Global Tool Configuration->
Global Tool Configuration中设置maven的home,如图

3.git集成

安装git,centos 默认安装了1.7版本的git,首先要卸载掉,然后在安装,安装完成后git相关的命令默认在
/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:
系统管理->Global Tool Configuration->
Global Tool Configuration中设置git的home,如图


参考: http://www.yingzinanfei.com/2016/09/22/centos-anzhuanggaobanbengit/

4. gitlab的集成

在Jenkins安装的服务器上, 创建一对rsa key, 在~/.ssh 生成一对密钥 id_rsa id_rsa.pub

ssh-keygen -t rsa -C "username@qq.com"
# 一路回车, 默认路径和文件名, 不要密码
cd ~/.ssh

将公钥id_rsa.pub 配置到 gitlab服务器中

将私钥配置jenkins 服务器中



username 填写 创建密钥对的username,key填写 id_rsa内容

5创建一个自动构建的job (gitlab maven tomcat)

选择maven 项目



Credentials 选择之前配置的私钥



goals 填写maven 的指令

构建完成后需要部署到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的自动构建完成。

相关文章

网友评论

      本文标题:Jenkins安装配置

      本文链接:https://www.haomeiwen.com/subject/rhwgqxtx.html