如何在特定时间通过另一个工作触发詹金斯工作? [英] How to trigger a Jenkins job by another job at a certain time?

查看:226
本文介绍了如何在特定时间通过另一个工作触发詹金斯工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个工作,JobA和JobB,JobA每天的运行时间为13.00,并记录一些付款.我希望JobA触发JobB来验证付款,前提是且仅当JobA成功且JobB需要在第二天的04.00运行

I have two jobs, JobA and JobB, JobA runs every day at 13.00 and registers some payments. I want JobA to trigger JobB which verifies the payments, if and only if JobA is successful and JobB needs to be run the next day at 04.00

有什么想法吗?

BR

推荐答案

我无法找到开箱即用的任何东西.当然,您可以安排要定期构建的作业,但这不是您想要的全部.

I have not been able to find anything that will do this out of the box. You can, of course, schedule a job to build periodically, but that's not all that you want.

您可以尝试以下两种想法之一(我自己也没有实现).

You could try one of these 2 ideas (I have not implemented either myself).

  1. 将JobB设置为在凌晨4点定期构建,但是停用该作业.如果JobA成功,则创建带有构建触发器的中间作业以进行构建(例如,在要监视的项目中设置JobA).中间作业将运行代码来激活JobB-使用groovy插件的groovy代码将是最简单的,或者您可以通过shell/batch脚本使用其余的api.然后,作为JobB中的最后一个构建步骤,运行类似的脚本以再次停用该作业.
  2. 通过计划生成插件,您可以安排将来的生成.但是,这似乎是一个手动过程.如果您可以弄清楚如何通过此插件以编程方式启动计划的构建,则可以将该代码添加到以与选项#1中所述相同的方式设置的中间作业中.
  1. Set JobB to build periodically at 4am, but deactivate the job. Create an intermediary job with a build trigger to build if JobA is successful (e.g. set JobA in the projects to watch section). The intermediary job would run code to activate JobB - groovy code using the groovy plugin would be easiest, or you could use the rest api via shell / batch script. Then as the last build step in JobB, run a similar script to deactivate the job again.
  2. The Schedule Build Plugin allows you to schedule future builds. However, it appears that this is a manual process. If you can figure out how to programatically fire off a scheduled build through this plugin, you could add that code to an intermediary job that is setup in the same way as mentioned in option #1.

这篇关于如何在特定时间通过另一个工作触发詹金斯工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆