-
Bug
-
Resolution: Unresolved
-
Minor
-
None
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.
- is related to
-
JENKINS-64024 changeset does not work when retrying a pipeline
-
- Open
-
There are two issues: one if you rebuild the project with the rebuilder plugin, another is the "restart from stage" functionality when using a pipeline which I believe is covered in https://issues.jenkins.io/browse/JENKINS-64024
The issues are the same: when a new build is scheduled, any ChangeSet information
For the issue with the rebuilder - it looks like all actions are copied over to the new build, and then a new Action is added (a rebuild action).
However, SCM data (in the case of workflow plugin) is kept in a seperate "checkouts" section:
https://javadoc.jenkins.io/plugin/workflow-job/org/jenkinsci/plugins/workflow/job/WorkflowRun.Checkouts.html
https://github.com/jenkinsci/workflow-job-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java#L823
One possible solution for the rebuilder plugin - and this would create a dependency on workflow plugin, but maybe it can be made optional - is to implement the onAddedTo() method - when added to a new run, inspect the previous run and copy over and checkouts