首页 > 其他 > 详细

Jenkins (自动化发布)

时间:2019-01-13 11:33:34      阅读:43      评论:0      收藏:0      [点我收藏+]

标签:自动   谢谢   nco   content   bubuko   color   pac   tail   1.0   

 

 

 

首先咱们需要安装一个 Jenkins,这个就不必多说了,晚上一搜索一大把,然后安装各种插件,配置各种环境变量,

今天我的实验环境是

使用Jenkins 拉取gitlap上项目的代码,然后自动编译并发布到tomcat中。

 

配置Jenkins

1、这里配置的就是你代码所存放的位置,还有你的项目名称和描述之类的

技术分享图片

 

2、配置触发器所需执行的一些东西,我这里配置了一个定时检测拉取的动作。

技术分享图片

3、配置tomcta

技术分享图片

 

 

这里要注意,最好单独创建一个账号,并赋予相关权限

<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
  <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
  <user username="role1" password="<must-be-changed>" roles="role1"/>
-->

<!-- <role rolename="admin"/> -->
<!-- <role rolename="admin-gui"/> -->
<!-- <role rolename="admin-script"/> -->
<!-- <role rolename="manager"/> -->
<!-- <role rolename="manager-gui"/> -->
<!-- <role rolename="manager-script"/> -->
<!-- <role rolename="manager-jmx"/> -->
<!-- <role rolename="manager-status"/> -->
<user name="admin" password="adminadmin" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="upload" password="upload" roles="manager-gui,manager-script"/>
</tomcat-users>

 

构建并查看日志

点击开始构建,然后查看输出日志结果,如果没有报错,大概就没有啥问题,说下我这里遇到的一个坑

 

技术分享图片

 

查看了一下大概报错原因,然后我将context关掉了,这个是否要求上下文路径,这个要看代码里pom文件里有没有强制要求,如果没有就不用写,

然后我清除了一下工作目录,自动部署成功日志输出也正常了,

解决问题链接地址:

 https://blog.csdn.net/alanzyy/article/details/60596402

http://www.alanzeng.cn/2017/03/jenkins-random-failed-deploy-tomcat/

 

正确输出

Started by user starry
Building in workspace /home/Jenkins-home/.jenkins/workspace/test-raymedy
Cloning the remote Git repository
remote: Counting objects
Receiving objects
Resolving deltas
Updating references
Checking out Revision 9ea6a0d4951c90b9c62cc9c03c4b3e575804e5ec (refs/remotes/origin/master)
Commit message: "Merge remote-tracking branch ‘origin/master‘"
Parsing POMs
Modules changed, recalculating dependency graph
Established TCP socket on 58075
[test-raymedy] $ /home/java/jdk1.8.0_65/bin/java -cp /home/Jenkins-home/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.11.jar:/home/maven339/boot/plexus-classworlds-2.5.2.jar:/home/maven339/conf/logging jenkins.maven3.agent.Maven33Main /home/maven339 /home/apache-tomcat-jenkins/webapps/ROOT/WEB-INF/lib/remoting-3.7.jar /home/Jenkins-home/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.11.jar /home/Jenkins-home/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar 58075
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f /home/Jenkins-home/.jenkins/workspace/test-raymedy/pom.xml install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building raymedy Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ raymedy ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 9 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ raymedy ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 114 source files to /home/Jenkins-home/.jenkins/workspace/test-raymedy/target/classes
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/FileTool.java:[11,16] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[5,16] sun.misc.BASE64Decoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[6,16] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/FileTool.java:[11,16] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[5,16] sun.misc.BASE64Decoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[6,16] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/FileTool.java:[11,16] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[5,16] sun.misc.BASE64Decoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[6,16] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/FileTool.java:[11,16] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[5,16] sun.misc.BASE64Decoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[6,16] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/FileTool.java:[389,26] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[38,20] sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/AESEncryptTool.java:[54,37] sun.misc.BASE64Decoder is internal proprietary API and may be removed in a future release
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/Message/SMSUtil.java: /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/Message/SMSUtil.java uses or overrides a deprecated API.
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Tools/Message/SMSUtil.java: Recompile with -Xlint:deprecation for details.
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Resources/BasicService.java: Some input files use unchecked or unsafe operations.
[WARNING] /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/com/topsci/Resources/BasicService.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ raymedy ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/Jenkins-home/.jenkins/workspace/test-raymedy/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ raymedy ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ raymedy ---
[INFO] No tests to run.
[JENKINS] Recording test results
[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ raymedy ---
[INFO] Packaging webapp
[INFO] Assembling webapp [raymedy] in [/home/Jenkins-home/.jenkins/workspace/test-raymedy/target/raymedy]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/Jenkins-home/.jenkins/workspace/test-raymedy/WebContent]
[INFO] Webapp assembled in [122 msecs]
[INFO] Building war: /home/Jenkins-home/.jenkins/workspace/test-raymedy/target/raymedy.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ raymedy ---
[INFO] Installing /home/Jenkins-home/.jenkins/workspace/test-raymedy/target/raymedy.war to /root/.m2/repository/raymedy/raymedy/1.0-SNAPSHOT/raymedy-1.0-SNAPSHOT.war
[INFO] Installing /home/Jenkins-home/.jenkins/workspace/test-raymedy/pom.xml to /root/.m2/repository/raymedy/raymedy/1.0-SNAPSHOT/raymedy-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.680 s
[INFO] Finished at: 2019-01-13T10:48:17+08:00
[INFO] Final Memory: 36M/551M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /home/Jenkins-home/.jenkins/workspace/test-raymedy/pom.xml to raymedy/raymedy/1.0-SNAPSHOT/raymedy-1.0-SNAPSHOT.pom
[JENKINS] Archiving /home/Jenkins-home/.jenkins/workspace/test-raymedy/target/raymedy.war to raymedy/raymedy/1.0-SNAPSHOT/raymedy-1.0-SNAPSHOT.war
channel stopped
Deploying /home/Jenkins-home/.jenkins/workspace/test-raymedy/target/raymedy.war to container Tomcat 7.x Remote with context 
  Redeploying [/home/Jenkins-home/.jenkins/workspace/test-raymedy/target/raymedy.war]
  Undeploying [/home/Jenkins-home/.jenkins/workspace/test-raymedy/target/raymedy.war]
  Deploying [/home/Jenkins-home/.jenkins/workspace/test-raymedy/target/raymedy.war]
Finished: SUCCESS

最终效果

技术分享图片

 

不足之处还请大家指教,谢谢啦

Jenkins (自动化发布)

标签:自动   谢谢   nco   content   bubuko   color   pac   tail   1.0   

原文:https://www.cnblogs.com/mjiu/p/10252333.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号