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 ]
          Ulli Hafner made changes -
          Remote Link New: This issue links to "PR #333 (Web Link)" [ 26939 ]
          Ulli Hafner made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Fixed but Unreleased [ 10203 ]

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

              Created:
              Updated:
              Resolved: