Jenkins插件开发环境搭建及调试方式 |
您所在的位置:网站首页 › jenkins启动tomcat › Jenkins插件开发环境搭建及调试方式 |
文章目录
Jenkins插件开发环境搭建基础环境配置maven的环境使用maven的命令创建一个创建设置idea中运行插件的方式配置插件的pom.xml文件使得idea可以运行访问的路径
启动与调试插件使用Hpi启动使用Tomcat启动远程调式方式
该篇文章介绍使用Idea进行jenkins插件开发的步骤(只涉及基本环境搭建和调试)
Jenkins插件开发环境搭建
基础环境
软件名称版本备注MavenApache Maven 3.6.1JAVA1.8.0_131IDEA2019.2
配置maven的环境
修改maven目录下的settings.xml文件。 org.jenkins-ci.tools jenkins true repo.jenkins-ci.org https://repo.jenkins-ci.org/public/ repo.jenkins-ci.org https://repo.jenkins-ci.org/public/ repo.jenkins-ci.org https://repo.jenkins-ci.org/public/ m.g.o-public 使用maven的命令创建一个创建使用如下命令创建一个新的插件 mvn org.jenkins-ci.tools:maven-hpi-plugin:create (或者 mvn hpi:create) 设置idea中运行插件的方式mvn hpi:run -Djetty.port =8090 基础配置项: -Djetty.port 设置端口 -DJENKINS_HOME 设置jenkins的数据目录 配置插件的pom.xml文件使得idea可以运行设置pom.xml文件 如果引入高版本jenkins需要设置日志的版本 8 2.190.1 1.7.26完整的pom.xml如下 4.0.0 org.jenkins-ci.plugins plugin 3.50 com.szkingdom.cicd.plugins wStatistics 1.0.0-RELEASE hpi TODO Plugin TODO https://wiki.jenkins-ci.org/display/JENKINS/TODO+Plugin MIT License http://opensource.org/licenses/MIT 8 2.190.1 1.7.26 3.2 repo.jenkins-ci.org http://repo.jenkins-ci.org/public/ repo.jenkins-ci.org http://repo.jenkins-ci.org/public/ 访问的路径继承Plugin类 可以通过/plugin/(插件名称)/ 访问 @ExportedBean public class wPlugin extends Plugin { @WebMethod(name = "test") public HttpResponse doTest(){ return HttpResponses.errorJSON("dd"); } } 启动与调试插件 使用Hpi启动1、添加maven启动项 2、修改maven的配置项 Command line: 命令行,mvn hpi:run -Djetty.port =8090 基础配置项: -Djetty.port 设置端口 -DJENKINS_HOME 设置jenkins的数据目录 使用Tomcat启动1、添加maven启动项 Working directory: 工作目录,也就是插件的根目录 Command line: 命令行,-Dmaven.tomcat.path=/ -DJENKINS_HOME=E:\WS\CompanyWS\ktmp\kt\main\jenkins\release\cicd-data -Dmaven.tomcat.port=8087 -Dmaven.tomcat.uriEncoding=UTF-8 tomcat:run 基础配置项 -Dmaven.tomcat.path : 访问路径 -DJENKINS_HOME :jenkins数据目录 -Dmaven.tomcat.port :tomcat启动的端口 -Dmaven.tomcat.uriEncoding :tomcat请求编码格式 远程调式方式1、将打包好的插件放在jenkins数据目录的plugins目录下 2、在使用以下的指令启动jenkins # 在插件的目录启动 set MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8095 mvn -Djetty.port=8090 hpi:run # 或者在已有的jenkins.war目录下运行 java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8095 -Dfile.encoding=GBK -Dpermissive-script-security.enabled=true -jar jenkins.war --ajp13Port=-1 --httpPort=87873、IDEA中使用remote进行调试 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |