使用REST创建作业并在jenkins中执行它们 [英] Create jobs and execute them in jenkins using REST
问题描述
我正在尝试创建一个WCF REST客户端,该客户端将与Jenkins通信并从XML文件创建作业,然后构建该作业.我的理解是,您可以使用Jenkins做到这一点.
I am trying to create a WCF REST client that will communicate to Jenkins and create a job from an XML file and then build the job. My understanding is that you can do that with Jenkins.
有人可以提供一些命令,您可以在浏览器的地址栏上键入这些命令来创建和构建作业吗?即:http:localhost/jenkins/createItem?name=TESTJOB
遵循这些原则.
Can some one please provide some commands that you can type on a browser's address bar to create and build jobs? ie: http:localhost/jenkins/createItem?name=TESTJOB
something along those lines.
推荐答案
请参见 Jenkins API Wiki页(包括末尾的评论).您可以使用Jenkins本身提供的文档来填补空白.例如,http://JENKINS_HOST/api
将为您提供创建作业的URL,而http://JENKINS_HOST/job/JOBNAME/api
将为您提供触发构建的URL.
See the Jenkins API Wiki page (including the comments at the end). You can fill in the gaps using the documentation provided by Jenkins itself; for example, http://JENKINS_HOST/api
will give you the URL for creating a job and http://JENKINS_HOST/job/JOBNAME/api
will give you the URL to trigger a build.
我强烈建议您避免自定义创建作业配置XML文件,而应查看 Job DSL插件.这为您提供了一个不错的基于Groovy的DSL,可通过编程方式创建作业-更加简洁,更不易出错.
I highly recommend avoiding the custom creation of job configuration XML files and looking at something like the Job DSL plugin instead. This gives you a nice Groovy-based DSL to create jobs programmatically - much more concise and less error-prone.
这篇关于使用REST创建作业并在jenkins中执行它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!