Using a very simple Jenkinsfile such as:
echo "Current build number: ${manager.build.number}"
if (manager.setBuildNumber(1)) {
echo "Build number is now: ${manager.build.number}"
manager.createSummary("gear2.gif").appendText("<h2>Testing</h2>", false)
}
The output is:
[Pipeline] echo
Current build number: 3
[Pipeline] echo
Build number is now: 3
[Pipeline] End of Pipeline
I expect the second echo to be build number 1. This means the manager.createSummary()
is getting applied to the current build number (3), not the intended one (1).
Any ideas? I've looked into the groovy-postbuild
source code and it looks like it is actually getting the build from build.getParent().getBuildByNumber(buildNumber)
as it's returning a not-null value, but perhaps the build it is returning is the current build regardless of what build number is provided?
FWIW, we are using the GitHub Organization and multi-branch plugins.