jenkinsjenkins-pipeline

Why does Jenkins calls getLastSuccessfulBuild consider unstable to be succesfull when there's a call for getLastUnstableBuild


Can someone tell me how I'd find last green build for jenkins 2.277?

After upgrading I found a behavior change where getLastSuccessfulBuild() returns the same value as getLastUnstableBuild()

Which means, when I promote, I can't trust these functions and need to write something to walk back through builds checking status.

In the scenario below:

last                Experiments/exp.Stability #6
last successful     Experiments/exp.Stability #6
last unstable       Experiments/exp.Stability #6
last failed         Experiments/exp.Stability #4

Solution

  • An unstable build in Jenkins is still considered functional and typically occurs when:

    If you want to fetch the last stable build, you can use the following API endpoint:

    https://JENKINS_DOMAIN/job/JOB_NAME/lastStableBuild/api/json