Hi all,
I have several dozen Jenkins jobs, split in to subcategories. For the sake of argument, let’s consider the “develop” and “release” subcategories. Each subcategory is governed by a “scheduler” job that parcels out jobs to various nodes, and (if all jobs in the subcategory are successful), updates a git branch and sends an email.
Everything we do is with the scripted pipeline (we have some complex non-standard requirements for how and when things are run, and hey, we’re developers - we like to write code). In order to make the above mechanism work, we do something like this:
myBuildJob = build job: buildJob
recordResult(myBuildJob)
And at the end of the scheduler pipeline we interrogate the storage variables and construct our email.
This works fine for jobs that succeed. However, we’re currently propagating errors from builds triggered by the scheduler. This seems like a robust way to prevent the git branch from updating if there are any problems. However, it appears that when myBuildJob fails, a groovy exception is raised and we never get to the recordResult() line.
(Side note: You can sort-of make this work with try/finally, but it’s really really ugly and appears to break error propagation anyway).
To me, the obvious next step is probably to disable error propagation and interrogate the result of each job in the scheduler pipeline before moving on to dependent jobs. However, this seems suspiciously like a re-implementation of the error propagating functionality, which makes me think I’ve not understood something properly…
I therefore have the following questions:
-
Is there a whitelisted way to get the last result of an arbitrary job? My googling suggests not. This would allow us to keep propagating errors and just interrogate all the results at the end. (Side note: we’re a few months away from a security audit and I don’t really understand the implications of allowing more groovy signatures, so I’ll need some convincing to use a non-whitelisted method),
-
Is my idea to manually check job results after failures a sensible one? I’m concerned that I’ve not understood the idiomatic way to deal with the above problem.
Thanks,
Tom