I am following this recent example and it does not seem to work for multibranch P4. All of the echo commands show that the changeset information is fully available, but the when changeset conditional never passes:
pipeline { agent { label 'master' } stages { stage("Test changeset"){ when { changeset "**/Jenkinsfile"} steps{ echo "The changeset test worked!!"} } stage("Display changeset?") { steps { script { def changeLogSets = currentBuild.changeSets for (int i = 0; i < changeLogSets.size(); i++) { def entries = changeLogSets[i].items for (int j = 0; j < entries.length; j++) { def entry = entries[j] echo "${entry.commitId} by ${entry.author} on ${new Date(entry.timestamp)}: ${entry.msg}" def files = new ArrayList(entry.affectedFiles) for (int k = 0; k < files.size(); k++) { def file = files[k] echo " ${file.editType.name} ${file.path}" } } } } }
Results:
[Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Test changeset) Stage "Test changeset" skipped due to when conditional [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Display changeset?) [Pipeline] script [Pipeline] { [Pipeline] echo 66 by jesse on Tue Nov 05 03:40:41 PST 2019: Polling time adjust [Pipeline] echo edit //streams/Dev-Jenkins/Jenkinsfile [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage
Is this a bug?
- is related to
-
JENKINS-58441 can I use changeset in when pipeline syntax
- Resolved