2

这是我的情况:

  1. 在大约 1 小时内在构建上运行的迷你测试套件
  2. 在大约 12 小时内在构建上运行的完整测试套件

我想连续触发(1),如果(1)PASSES,那么我想触发(2)。

但是,当构建稳定且 (1) 频繁通过时,我不想排队 (2) 的大量作业。如何在 Jenkins 中进行设置?我能想到的两种可能的解决方案是

  • 不知何故,永远不允许 Jenkins 在 (2) 上保留作业队列,或者
  • 仅在尚未运行时触发 (2)

但我也不知道该怎么做,有什么想法吗?

4

1 回答 1

0
A possible solution for : only trigger (2) if it's not already running

All jenkins jobs have their data exposed in XML and json format via this URL:
*http://jenkins_hostname/job/job_name/build_number/api/xml*

This XML has a section of <building> in which you will know if the job is building or not:
<building> false </building>


If you can somehow read this from scripts?/code? then you will always know if job is running.

Otherwise, there is a boolean groovy API which reads this data and returns true or false (can be used easily in pipelines):

*def JobName = 'JOB_NAME'
def nextJob = Hudson.instance.getItem(JobName)
def running = nextJob.lastBuild.building
if (running) {
   println "${nextJobName} is already running. Not launching"
} else {
   println "${nextJobName} is not running. Launching..."
}*
于 2021-11-17T08:25:13.420 回答