一、Jenkins的介绍
Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,
旨在提供一个开放易用的软件平台,使软件的持续集成变成可能。
二、功能
Jenkins功能包括:1、持续的软件版本发布/测试项目。2、监控外部调用执行的工作。
三、安装及启动
首先保证系统中已经安装了jdk。
启动方法一.
切换到jenkins.war(V2.121.1)存放的目录,输入如下命令:java -jar jenkins.war
如果需要修改端口可以使用如下命: java -jar jenkins.war--httpPort=8081
然后在浏览器中打开链接 localhost:8080/jenkins
2.将jenkins.war文件放入tomcat下的webapps目录下
3.进入tomcat下的/bin目录(cd /thirdparties/apache-tomcat-backend/bin),启动tomcat:sh startup.sh
The file is absent or does not have execute permission
This file is needed to run this program
则输入:chmod 777 *.sh
安装SSH插件:系统管理->管理插件->可选插件
SSH过滤->SSH直接安装
用户名:admin 密码:admin
如果要修改密码:
vim /Users/abel/.jenkins/users/admin/config.xml
改为:<passwordHash>#jbcrypt:$2a$10$ohx6TGUxd9cBuswQ9kFH2OOyTZX8wg1E1EIikbpwfbNj4qF7yeysK</passwordHash>
重新启动jenkins,新密码为:admin
至此jenkins部署成功,如果报:反向代理设置有误
反向代理报错解决方法:打开系统管理-->系统设置-->Jenkins URL
将localhost改为127.0.0.1,Jenkins URL:http://127.0.0.1:8088/jenkins/
附:https://wiki.jenkins.io/display/JENKINS/Jenkins+says+my+reverse+proxy+setup+is+broken
UTF-8编码问题解决办法:
<Connector connectionTimeout="20000" port="8088" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8" />
四、配置
系统管理->系统设置
1.SSH remote hosts
2.Jenkins Location
五、项目部署
1.项目描述及环境配置
2.源码管理
${BRANCH}
3.构建
mvn clean package -Dmaven.test.skip -U -P${ENV} echo ${WORKSPACE}
echo ${JOB_NAME}
echo ${BUILD_ID}
timeStamp=`date +%Y-%m-%d`
echo $timeStamp
mkdir -p /thirdparties/jenkins/apache-tomcat/webapps/docs/build/${JOB_NAME}/$timeStamp@${BUILD_NUMBER}
mv ${WORKSPACE}/backendrpc/target/backendrpc-bin.zip /thirdparties/jenkins/apache-tomcat/webapps/docs/build/${JOB_NAME}/$timeStamp@${BUILD_NUMBER}
mv ${WORKSPACE}/backendrest/target/backendrest.war /thirdparties/jenkins/apache-tomcat/webapps/docs/build/${JOB_NAME}/$timeStamp@${BUILD_NUMBER}
/apps/unpacking_dynamic.sh ${JOB_NAME} ${BUILD_NUMBER}
unpacking_dynamic.sh 文件代码为:
echo $ $
timeStamp=`date +%Y-%m-%d`
echo $timeStamp@$ cd /apps/
wget http://172.16.133.65:8090/docs/build/$1/$timeStamp@$2/backendrest.war -nH -r -N -nv
wget http://172.16.133.65:8090/docs/build/$1/$timeStamp@$2/backendrpc-bin.zip -nH -r -N -nv
ps aux |grep java |grep apache-tomcat-common |grep -v grep |grep -v tail |awk '{print $2}' |xargs kill - echo "stop backendrpc..."
ps aux |grep java |grep backendrpc |grep -v grep |grep -v tail |awk '{print $2}' |xargs kill
sleep
cd /apps/
rm -rf backendrest/
rm -rf backendrpc/
unzip -qo ./docs/build/$/$timeStamp@$/backendrest.war -d backendrest
unzip -q ./docs/build/$/$timeStamp@$/backendrpc-bin.zip source /etc/profile cd ./backendrpc/sh
chmod start.sh
./start.sh conf1 sleep
/thirdparties/apache-tomcat-common-/bin/startup.sh
sleep
至此,Jenkins的安装配置及通过Jenkins部署项目的介绍告一段落。
附:
https://blog.csdn.net/qq_26848099/article/details/78901240
https://www.yiibai.com/jenkins/jenkins_setup_build_jobs.html#article-start