How to poll Jenkins SCM during job execution

So, I inherited a slightly weird setting (changing the time would be tedious):

I am using Jenkins with SCM polling (Perforce) but the running job does not use the SCM Workspace in any way other than the startup itself. The assembly then outputs the latest version and builds from it. This setup works, but creates unnecessary lag:

10:00 submit Rev#100001
10:05 SCM polls this and queue a build job#101
10:06 job#101 start (will take ~2H)
10:30 submit Rev#100002
10:35 SCM polls this and queue a build job#102
11:00 submit Rev#100003
11:35 SCM polls this and queue a build job#103
12:00 job#101 exits
12:01 job#102 start (will take ~2H)

      

Now, not accepting any new proposals job#103

is unnecessary repetition job#102

.


Update: From @ Slav's answer, I realized that I wasn't clear enough. The fact that the SCM trigger is not associated with pulling the codebase causes this abnormality:

job#101 reports that it was triggered by Rev#100001 and builds from Rev#100001
job#102 reports that it was triggered by Rev#100002 and builds from Rev#100003
job#103 reports that it was triggered by Rev#100003 and builds from Rev#100003

      

This also explains why there is more than one queued run: from Jenkins'es POV, each queued build is different.


I want to eliminate this lag.

This can be done, for example,

  • When job # 101 is running, do not try SCM (best option)
  • When job # 103 is queued, delete job # 102 if it has not started yet.
  • in any other way?

Is it possible? And if so, how?

+3


source to share


1 answer


Are you sure this is happening? I have never seen more than one queue in a queue, even if there are multiple triggers in between.

When I've had scenarios where a build was taking longer to poll, the easiest way to fix it manually was to disable the task after it started (and re-enable it after it finished), but this is only useful in case of exceptions and manual intervention.



If you want it for automation, you should look at the advanced quiet period options (in the Job Configuration section).

0


source







All Articles