0

I've got two types of failures to account for within a Jenkins job.

  1. The job genuinely failed
  2. The job failed because of a certain bit of info hasn't been published. Nothing is actually wrong here.

How do I handle the 2nd case so it shows the job did no complete, but nothing is actually wrong?

1

One possibility would be to place the checks for all the necessary pre-conditions (i.e. including those bits of info that would need to be published) in a separate build step to be executed prior to the actual build step.

If the checks in this preliminary step fail the build could be marked as aborted instead of failed. The aborted build would, hopefully, be a better indication that "nothing is actually wrong" (debatable, I know).

Marking the build as aborted could maybe be done in a manner similar to these SO answers:

If those checks cannot be pulled in a step separated from the actual build step things are a bit more complicated:

  • the actual build step would have to somehow be configured to not fail the job. I know it's possible for steps performed in virtual environments using the ShiningPanda plugin, but other types of steps do not have such capability.
  • an additional step would have to be added after the actual build step. Its job would be to somehow determine if the actual build step failed and, if so, if failure was causing by one of those unfulfilled pre-requisite conditions (maybe by parsing the build logs, for example?), in which case it would abort the build. Otherwise it would pass or fail, depending on the actual build step outcome, to properly indicate the overall run status in Jenkins.
1
  • This is effectively what I went for in the end. Do a check against some criteria in the first step, then abort if the test fails. Not the 'cleanest' method, but it works well enough and the only people who'll be looking at it are myself and the rest of my team – Alistair Hardy Feb 21 '20 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.