• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins v2.23, Bitbucket branch source plugin v1.8

      This is a regression from v1.7. In v1.7 I could test whether PR is being built with 'env.BRANCH_NAME.startsWith("PR-")', and in v1.8 'env.BRANCH_NAME' is set to name of branch from which pull request originates. This is OK for me, but the I would expect 'env. CHANGE_ID' to be set to non-null and contain information about pull request number. However, in v1.8 CHANGE_ID is null even for pull requests, while BRANCH_NAME contains name of branch for both pull requests and branches.

      How to detect from script whether PR or branch is being built? I want different build behaviour for PRs and feature branches.

          [JENKINS-38419] Unable to detect PullRequest anymore

          Justen Britain added a comment - Related: https://issues.jenkins-ci.org/browse/JENKINS-40486

          Nikolas Falco added a comment -

          I our pipeline script library we reconize is PR in this manner:

          /vars/pullRequest.groovy

          Integer getId() {
              String prId = env.CHANGE_ID
              if ( ! prId ) {
                  return null
              } else {
                  return prId as int
              }
          } 

          if pullrequest.getId() means it's a PR than we skip some steps like deploy

          When event comes from branch that is a PR than CHANGE_ID is valued with the pullrequest number, null otherwise

          Nikolas Falco added a comment - I our pipeline script library we reconize is PR in this manner: /vars/pullRequest.groovy Integer getId() {     String prId = env.CHANGE_ID     if ( ! prId ) {         return null     } else {         return prId as int     } } if pullrequest.getId() means it's a PR than we skip some steps like deploy When event comes from branch that is a PR than CHANGE_ID is valued with the pullrequest number, null otherwise

            nfalco Nikolas Falco
            dodoent Nenad Miksa
            Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: