-
Improvement
-
Resolution: Fixed
-
Minor
When Jenkins is building pull request (either the source branch or the result of merging), the discoverReferenceBuild and discoverGitReferenceBuild steps could choose a reference build from the job corresponding to the target branch of the pull request, by default. This way, the pipeline would not need to pass in defaultBranch: env.CHANGE_TARGET explicitly.
The precedence could be:
- referenceJob: argument
- target branch of the pull request, from ChangeRequestSCMHead.getTarget()
- defaultBranch: argument
- PrimaryInstanceMetadataAction, if
JENKINS-66689is implemented - hardcoded DEFAULT_BRANCH = "master"
This could be implemented by making ReferenceRecorder in forensics-api-plugin call ChangeRequestSCMHead.getTarget() if available, and use the result as the reference branch, instead of the default branch (which can be set with ReferenceRecorder.setDefaultBranch or defaults to "master"). SimpleReferenceRecorder.setReferenceJob would still bypass the multibranch support altogether, and use exactly the job that you specify.
- is related to
-
JENKINS-66689 Use PrimaryInstanceMetadataAction for choosing default reference branch
-
- Resolved
-
-
JENKINS-66480 Reference build is wrong for PRs
-
- Resolved
-
-
JENKINS-66581 Implement ChangeRequestSCMHead2 for pull requests
-
- Closed
-
- links to
I am not sure which of these should take precedence:
If the pipeline computes defaultBranch with a complex expression but the step then ignores it for pull requests, I think the developer will be surprised. However, the name of the parameter has “default” in it, which implies that it should not take effect if there is more specific information available.