Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-60028

Jenkinsfile when changeset skipped if already built

XMLWordPrintable

      I had a Jenkinsfile like this:

      stage ('Test') {{{    when { changeset 'foo.txt' }}}
          steps { echo 'foo.txt in changeset' }}}{

      If I push a commit that changes foo.txt, the stage executes, as expected. But if I retrigger a build of that same commit, the stage gets skipped. Worse, this happens even if the first build fails.

      Is this the expected behavior? If so, I don't see how changeset could ever be useful. For example, imagine we wanted to run a linter on a file, but only if that file has changed. A developer makes changes, the stage executes, and the linter fails. Then that developer triggers another build, the stage gets skipped, and now the build passes. This defeats the entire point.

      From what I've gathered, the changeset condition is comparing the incoming commit hash with the one from the previous build. But that leads to big problems if the previous build failed, or was for the same commit. I suggest the following rules: If the previous build failed (i.e., was not "SUCCESS"), or was for the same commit, that build's changeset(s) must be added to the the new build's list of changeset.

            Unassigned Unassigned
            rittneje Jesse Rittner
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: