Marcus Müller a.k.a. "Tethpub ZNeK"
crack-admin/coder™

A Jenkins problem and its solution

28.09.2017

A periodically running Python service (frequency: every 5 minutes!) should be migrated to Jenkins (via ShiningPanda Plugin ), to ease supervision and log observation/rotation. Its source code is located in a Git repository and is being updated from time to time (very infrequently).

Problem

The Jenkins job will run every 5 minutes - and will also check for SCM changes before it runs, resulting in unnecessary load on the SCM service and (very short) delay during each job run. I checked quite a number of Jenkins plugins, but there doesn't seem to be a single one which allows to conditionally disable SCM checks, which would do the trick:

Check and update SCMpip -r requirements.txtyesIs job run manually?Run Python script

Solution

I probably could have written my own plugin, but I chose to plumb together stuff that already existed. It turns out that Conditional BuildStep Plugin is all I needed. Splitting the problem into two separate, but dependent, Jobs src and run, this is how it works:

srcCheck and update SCMsource andrequirements.txtArchive artifactsTriggerrunjobrunConditional BuildStep PluginGet artifacts fromsrcpip -r requirements.txtyesIs job run because of upstream?Run Python scriptwait 5 minutes