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

Use pull request target branch for reference build by default

      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:

      1. referenceJob: argument
      2. target branch of the pull request, from ChangeRequestSCMHead.getTarget()
      3. defaultBranch: argument
      4. PrimaryInstanceMetadataAction, if JENKINS-66689 is implemented
      5. 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.

          [JENKINS-66672] Use pull request target branch for reference build by default

          Kalle Niemitalo created issue -
          Kalle Niemitalo made changes -
          Description Original: 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 of the pull request, from [ChangeRequestSCMHead.getTarget()|https://javadoc.jenkins.io/plugin/scm-api/jenkins/scm/api/mixin/ChangeRequestSCMHead.html#getTarget()]
          # {{defaultBranch:}} argument
          # [hardcoded DEFAULT_BRANCH = "master"|https://github.com/jenkinsci/forensics-api-plugin/blob/95d289a396e009ff0c165b47a40505d3ca8420bc/src/main/java/io/jenkins/plugins/forensics/reference/ReferenceRecorder.java#L44]

          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.
          New: 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()|https://javadoc.jenkins.io/plugin/scm-api/jenkins/scm/api/mixin/ChangeRequestSCMHead.html#getTarget()]
          # {{defaultBranch:}} argument
          # [hardcoded DEFAULT_BRANCH = "master"|https://github.com/jenkinsci/forensics-api-plugin/blob/95d289a396e009ff0c165b47a40505d3ca8420bc/src/main/java/io/jenkins/plugins/forensics/reference/ReferenceRecorder.java#L44]

          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.
          Kalle Niemitalo made changes -
          Link New: This issue is related to JENKINS-66480 [ JENKINS-66480 ]
          Kalle Niemitalo made changes -
          Link New: This issue is related to JENKINS-66581 [ JENKINS-66581 ]
          Kalle Niemitalo made changes -
          Link New: This issue relates to JENKINS-66689 [ JENKINS-66689 ]
          Kalle Niemitalo made changes -
          Link New: This issue is related to JENKINS-66689 [ JENKINS-66689 ]
          Kalle Niemitalo made changes -
          Link Original: This issue relates to JENKINS-66689 [ JENKINS-66689 ]
          Kalle Niemitalo made changes -
          Description Original: 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()|https://javadoc.jenkins.io/plugin/scm-api/jenkins/scm/api/mixin/ChangeRequestSCMHead.html#getTarget()]
          # {{defaultBranch:}} argument
          # [hardcoded DEFAULT_BRANCH = "master"|https://github.com/jenkinsci/forensics-api-plugin/blob/95d289a396e009ff0c165b47a40505d3ca8420bc/src/main/java/io/jenkins/plugins/forensics/reference/ReferenceRecorder.java#L44]

          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.
          New: 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()|https://javadoc.jenkins.io/plugin/scm-api/jenkins/scm/api/mixin/ChangeRequestSCMHead.html#getTarget()]
          # {{defaultBranch:}} argument
          # PrimaryInstanceMetadataAction, if JENKINS-66689 is implemented
          # [hardcoded DEFAULT_BRANCH = "master"|https://github.com/jenkinsci/forensics-api-plugin/blob/95d289a396e009ff0c165b47a40505d3ca8420bc/src/main/java/io/jenkins/plugins/forensics/reference/ReferenceRecorder.java#L44]

          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.
          Ulli Hafner made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          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.

          Kalle Niemitalo added a comment - I am not sure which of these should take precedence: target branch of the pull request, from ChangeRequestSCMHead.getTarget() defaultBranch: argument 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.

            drulli Ulli Hafner
            kon Kalle Niemitalo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: