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

Implement ChangeRequestSCMHead2 for pull requests

    • 4.0.0

      As of PR #253 and version 3.0.0, the Bitbucket Server Integration plugin can generate Jenkins jobs for source branches of pull requests, but not for the pull requests themselves.

      It would be useful to have a Jenkins job for the pull request itself and let other plugins query information about it. In particular, Branch API would call ChangeRequestSCMHead#getTarget() and set the CHANGE_TARGET global variable, which could then be passed to the discoverGitReferenceBuild pipeline step in order to let Warnings Next Generation compare the build warnings of the pull request to those of its target branch.

      This would require the Bitbucket Server Integration plugin to define and use a class that implements the ChangeRequestSCMHead2 interface, like the GitHub Branch Source, Bitbucket Branch Source, Gitea, and P4 plugins already do. Currently, BitbucketWebhookConsumer.BitbucketSCMHeadPullRequestEvent just uses GitBranchSCMHead.

          [JENKINS-66581] Implement ChangeRequestSCMHead2 for pull requests

          Kalle Niemitalo created issue -
          Kalle Niemitalo made changes -
          Description Original: As of [PR #253|https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin/pull/253], the Bitbucket Server Integration plugin can generate Jenkins jobs for source branches of pull requests, but not for the pull requests themselves.

          It would be useful to have a Jenkins job for the pull request itself and let other plugins query information about it. In particular, [Branch API|https://github.com/jenkinsci/branch-api-plugin/blob/0f9cf838b6298d21652400dde9d611b3374f5b60/src/main/java/jenkins/branch/BranchNameContributor.java#L70-L71] would call [ChangeRequestSCMHead#getTarget()|https://github.com/jenkinsci/scm-api-plugin/blob/400faa8fd5651731257ff59f53b715dfeede7ede/src/main/java/jenkins/scm/api/mixin/ChangeRequestSCMHead.java#L50-L57] and set the {{CHANGE_TARGET}} global variable, which could then be passed to the [discoverGitReferenceBuild|https://www.jenkins.io/doc/pipeline/steps/git-forensics/#discovergitreferencebuild-discover-git-reference-build] pipeline step in order to let [Warnings Next Generation|https://plugins.jenkins.io/warnings-ng/] compare the build warnings of the pull request to those of its target branch.

          This would require the Bitbucket Server Integration plugin to define and use a class that implements the [ChangeRequestSCMHead2|https://github.com/jenkinsci/scm-api-plugin/blob/400faa8fd5651731257ff59f53b715dfeede7ede/src/main/java/jenkins/scm/api/mixin/ChangeRequestSCMHead2.java] interface, like the [GitHub Branch Source|https://github.com/jenkinsci/github-branch-source-plugin/blob/d07e7d20a8458a2a1288ddbb85134abe30805119/src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMHead.java#L48], [Bitbucket Branch Source|https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/c79f7c340cac7455b90d963bdaba9f4fb7dd2c25/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/PullRequestSCMHead.java#L48], [Gitea|https://github.com/jenkinsci/gitea-plugin/blob/62855b3c3d8c119302b1156f5d3b0b3460810f76/src/main/java/org/jenkinsci/plugin/gitea/PullRequestSCMHead.java#L32], and [P4|https://github.com/jenkinsci/p4-plugin/blob/4a564282febb6a94a5833c02c0fce1f3d7e657cc/src/main/java/org/jenkinsci/plugins/p4/scm/P4ChangeRequestSCMHead.java#L12] plugins already do. Currently, `BitbucketWebhookConsumer.BitbucketSCMHeadPullRequestEvent` just [uses GitBranchSCMHead|https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin/blob/470a7380c0f4141635371ff178c66103ff6bf49c/src/main/java/com/atlassian/bitbucket/jenkins/internal/trigger/BitbucketWebhookConsumer.java#L255-L256].
          New: As of [PR #253|https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin/pull/253], the Bitbucket Server Integration plugin can generate Jenkins jobs for source branches of pull requests, but not for the pull requests themselves.

          It would be useful to have a Jenkins job for the pull request itself and let other plugins query information about it. In particular, [Branch API|https://github.com/jenkinsci/branch-api-plugin/blob/0f9cf838b6298d21652400dde9d611b3374f5b60/src/main/java/jenkins/branch/BranchNameContributor.java#L70-L71] would call [ChangeRequestSCMHead#getTarget()|https://github.com/jenkinsci/scm-api-plugin/blob/400faa8fd5651731257ff59f53b715dfeede7ede/src/main/java/jenkins/scm/api/mixin/ChangeRequestSCMHead.java#L50-L57] and set the {{CHANGE_TARGET}} global variable, which could then be passed to the [discoverGitReferenceBuild|https://www.jenkins.io/doc/pipeline/steps/git-forensics/#discovergitreferencebuild-discover-git-reference-build] pipeline step in order to let [Warnings Next Generation|https://plugins.jenkins.io/warnings-ng/] compare the build warnings of the pull request to those of its target branch.

          This would require the Bitbucket Server Integration plugin to define and use a class that implements the [ChangeRequestSCMHead2|https://github.com/jenkinsci/scm-api-plugin/blob/400faa8fd5651731257ff59f53b715dfeede7ede/src/main/java/jenkins/scm/api/mixin/ChangeRequestSCMHead2.java] interface, like the [GitHub Branch Source|https://github.com/jenkinsci/github-branch-source-plugin/blob/d07e7d20a8458a2a1288ddbb85134abe30805119/src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMHead.java#L48], [Bitbucket Branch Source|https://github.com/jenkinsci/bitbucket-branch-source-plugin/blob/c79f7c340cac7455b90d963bdaba9f4fb7dd2c25/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/PullRequestSCMHead.java#L48], [Gitea|https://github.com/jenkinsci/gitea-plugin/blob/62855b3c3d8c119302b1156f5d3b0b3460810f76/src/main/java/org/jenkinsci/plugin/gitea/PullRequestSCMHead.java#L32], and [P4|https://github.com/jenkinsci/p4-plugin/blob/4a564282febb6a94a5833c02c0fce1f3d7e657cc/src/main/java/org/jenkinsci/plugins/p4/scm/P4ChangeRequestSCMHead.java#L12] plugins already do. Currently, BitbucketWebhookConsumer.BitbucketSCMHeadPullRequestEvent just [uses GitBranchSCMHead|https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin/blob/470a7380c0f4141635371ff178c66103ff6bf49c/src/main/java/com/atlassian/bitbucket/jenkins/internal/trigger/BitbucketWebhookConsumer.java#L255-L256].
          Kalle Niemitalo made changes -
          Link New: This issue depends on JENKINS-60342 [ JENKINS-60342 ]

          Kalle Niemitalo added a comment - - edited

          Then you can also add the pull request title as ObjectMetadataAction like Bitbucket Branch Source does. From there, JENKINS-55348 https://github.com/jenkinsci/branch-api-plugin/pull/254 can use it.

          Kalle Niemitalo added a comment - - edited Then you can also add the pull request title as ObjectMetadataAction like Bitbucket Branch Source does . From there, JENKINS-55348 https://github.com/jenkinsci/branch-api-plugin/pull/254 can use it.
          Kalle Niemitalo made changes -
          Link New: This issue is related to JENKINS-66672 [ JENKINS-66672 ]
          Michal made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Michal made changes -
          Status Original: In Progress [ 3 ] New: Open [ 1 ]

          BitbucketSCMSource.DescriptorImpl.createCategories() (source) should also include a ChangeRequestSCMHeadCategory (source, javadoc) in the array that it returns, like in Bitbucket Branch Source (source).

          Kalle Niemitalo added a comment - BitbucketSCMSource.DescriptorImpl.createCategories() ( source ) should also include a ChangeRequestSCMHeadCategory ( source , javadoc ) in the array that it returns, like in Bitbucket Branch Source ( source ).

          Kalle Niemitalo added a comment - - edited

          If you copy the description of the pull request to the ObjectMetadataAction, then the Pull Request Monitoring plugin (source) can display it. I suppose this would require registering the webhook for the "pr:modified" event as well, so that you can update the description in Jenkins when someone edits it in Bitbucket Server.

          (The Bitbucket Branch Source plugin does not copy the PR description to ObjectMetadataAction yet.)

          Kalle Niemitalo added a comment - - edited If you copy the description of the pull request to the ObjectMetadataAction, then the Pull Request Monitoring plugin ( source ) can display it. I suppose this would require registering the webhook for the "pr:modified" event as well, so that you can update the description in Jenkins when someone edits it in Bitbucket Server. (The Bitbucket Branch Source plugin does not copy the PR description to ObjectMetadataAction yet.)
          Kalle Niemitalo made changes -
          Link New: This issue is duplicated by JENKINS-66786 [ JENKINS-66786 ]

            Unassigned Unassigned
            kon Kalle Niemitalo
            Votes:
            17 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved: