Jenkins2.40+Gitee+Maven+Tomcat8.5.56

Jenkins2.40 +Gitee +Maven3.6.3 +Tomcat8.5.56

Maven插件Maven Integration plugin
发布插件Deploy to container Plugin
git插件Git plugin
gitee插件 Gitee




1.免安装版启动服务
cd D:\Program Files\Jenkins
java -jarJenkins.war --httpPort=8089
Jenkins默认的端口号是8080,修改方法:java -jar jenkins.war --ajp13Port=-1 --httpPort=8081


windows安装版msi文件启动服务 2.启动Jenkins服务
net start jenkins(注:如果Jenkins曾经启动过,启动服务不需要进入到某个目录)
3.停止Jenkins服务
net stop jenkins


一、安装插件
Plugin插件安装失败 【Jenkins2.40+Gitee+Maven+Tomcat8.5.56】对于maven integration安装失败:
http://updates.jenkins-ci.org/download/plugins/maven-plugin/2.14/maven-plugin.hpi
其他插件安装不了可以去搜索插件离线安装:
http://updates.jenkins-ci.org/download/plugins


该插件是用来将war包发布到服务器上
Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
发布插件 通过手动安装,插件管理(Plugin Manager)-->高级 -->上传插件
安装完插件后,进行全局工具配置
二、全局工具配置

Manage Jenkins-- Global Tool Configuration
JDK
Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
JDK配置 注意:Oracle需要提供账号,才能下载JDK。

Git
Git客户端下载
Path to Git executable填写机上的安装路径D:\Program Files\Git\bin\git.exe
Maven
Install from Apache选择版本就可以了
记得要保存
三、(New Item)创建任务


Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
创建项目

Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
Gitee账号 配置Git只要填写Repository URL仓库地址
(Credentials)证书后面点击(Add)添加,输入Gitee 登录的用户名密码,Description输入一个描述便于区分
Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
Gitee 用户 其他不需要修改


Build Triggers(构建触发器)
设置轮询SCM为每15分钟轮询一次,此处的编写规则遵循crontab 任务的周期编写规则。
Poll SCM
H/15 * * * *


填写红色框内容clean package -Dmaven.test.skip=true
Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
Bulid 点击 Add post-bulid action选择 Deploy war/ear to container 接着选择发布到容器(Tomcat x、JBoss x等容器)


WAR/EAR files 填写**/target/*.war
如果路径不对会报如下错误:
ERROR: Step ‘Deploy war/ear to a container’ aborted due to exception:
java.lang.InterruptedException: [DeployPublisher][WARN] No wars found. Deploy aborted. %n


Context path 填写/test(只填写/ 就会是替换你的ROOT,生成一个ROOT.war,填写/test 生成一个test.war)


Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
Tomcat配置 点击Add(添加) 选择 Jenkins
Add Credentials页面红框全出来的userName 、Password填写Tomcat你配置的用户密码
Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
Add Credentials

如下错误说明是Tomcat权限错误:
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username you provided is not allowed to use the text-based Tomcat Manager (error 403)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL:http://192.168.0.113:8080/manager/text/list at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:577)... 21 more
找自己Tomcat服务路径:
D:\apache-tomcat-8.5.56\webapps\manager\META-INF\context.xml

修改为:

或者



配置tomcat远程部署账号,在tomcat目录下conf文件内tomcat-users.xml 文件增加以下配置:







记得Save(保存)


如果Build Now你出现下面的这个错误,说明你来到一个最坑爹的问题,只要把Containers 换成Tomcat 7.x Remote 配置不变:
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [C:\Users\Administrator\.jenkins\workspace\test_OA\ruoyi-admin\target\ruoyi-admin.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:184)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:81)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:167)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:136)
at hudson.FilePath.act(FilePath.java:1075)
at hudson.FilePath.act(FilePath.java:1058)
at hudson.plugins.deploy.CargoContainerAdapter.redeployFile(CargoContainerAdapter.java:133)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeployFile(PasswordProtectedAdapterCargo.java:95)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:113)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1074)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1905)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:428)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The Tomcat Manager responded


通过创建的项目进图
Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片
项目 Bulid Now构建运行
Configure配置
Build History构建任务 :查看运行的状态,日志


删除Build History
jenkins –> 系统管理 --> 脚本命令行
以下是脚本命令
https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/bulkDeleteBuilds.groovy
修改jobName 和buildRange 这两个参数。
我的默认jenkins目录 C:\Users\Administrator\.jenkins\jobs下对应的jobName。
Jenkins2.40+Gitee+Maven+Tomcat8.5.56
文章图片

    推荐阅读