如何陆续执行参数化的工作(无参数) [英] How to run parametrized job after another (without params)
问题描述
我在詹金斯(Jenkins)有一份工作,其中有2个参数.我想运行另一个没有参数的计划,并从该计划中启动所需的现有计划多次.
I have a job in Jenkins which has 2 params. I want to run another plan, which has no params and from that plan, launch the existing plan as many times as required.
新计划需要安排为每15分钟运行一次(将由Jenkins的Scheduler选项完成),该计划的代码将:
The new plan needs to be scheduled to run each 15 minutes (will be done by Jenkins' scheduler option), the code of that plan will:
- 连接到数据库
- 获取所需的记录集
- 开始循环记录集
- 存储键/值对(现有作业的参数)
- connect to a db
- get required recordset
- start looping the recordset
- store the key/value pair (parameters for the existing job)
完成此操作后,我需要使用已存储的每个键/值对运行现有作业.我可以使用Jenkins(使用1.406)开箱即用吗,还是必须远程调用现有作业? 使用构建后操作"部分(规划配置)中的构建其他项目"选项时,我看不到如何将参数从一个计划传递给另一个计划
Once this is done, I need to run the existing job with each key/value pair that was stored. Can I do it like this out of the box with Jenkins (using 1.406) or do I have to call the existing job remotely? I don't see how to pass parameters from one plan to another when using the "Build other projects" option in the "Post-build Actions" section (configuration of a plan)
谢谢
推荐答案
There is a Parameterized Trigger Plugin which, once installed, allows you to trigger a parameterized build after one build has finished.
完成所需操作的最简单方法是安装此插件,并使用要构建的键/值列表一次构建项目.如果由于某些原因您需要在第一个作业完成后多次执行构建,则可以使用远程API从第一个项目开始构建.因此,您有两种选择:
The easiest way to accomplish what you want would be to install this plugin, and build the project once with the key/value list that you want to build against. If for some reason you need to execute the build multiple times after the first job completes, then you could use the remote API to start builds from your first project. So you have two options:
选项A
- Project1执行,创建具有键/值对的文件
- Project1完成,配置为使用参数执行Project2(使用参数化触发器插件)
- Project2遍历键/值对,为每个键/值做任何事情
选项B
- Project1执行.对于每个键/值对,它都会到达以下URL
http://server/job/<Project2 Name>/buildWithParameters?PARAM1=Value1&PARAM2=Value2
(您将需要替换为实际的项目名称和参数名称/值) - Project2会采用这些参数并按需要正常使用参数值进行构建
- Project1 executes. For every key/value pair, it hits the following url
http://server/job/<Project2 Name>/buildWithParameters?PARAM1=Value1&PARAM2=Value2
(you will need to substitute in your actual project name and parameter names/values) - Project2 takes these parameters and builds as normal, using the parameter values wherever it needs to
这篇关于如何陆续执行参数化的工作(无参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!