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

Cannot get source branch in PR build in Bitbucket team project

    XMLWordPrintable

Details

    Description

      I need to get JIRA issue key from the name of the branch, but from the PR build I cannot obtain in. Source branch name is not listed in the 'env' list. It would be useful if we could somehow obtain the source branch name from the PR build

      Attachments

        Activity

          marcinl Marcin L added a comment - - edited

          I updated to the latest 2.0.11 but still I can't get the source branch name. It's always set to "PR-" but I think it should be set to `head.ref` from Github api?

          marcinl Marcin L added a comment - - edited I updated to the latest 2.0.11 but still I can't get the source branch name. It's always set to "PR-" but I think it should be set to `head.ref` from Github api?
          jglick Jesse Glick added a comment -

          marcinl $CHANGE_BRANCH

          jglick Jesse Glick added a comment - marcinl $CHANGE_BRANCH
          marcinl Marcin L added a comment -

          I checked and $CHANGE_BRANCH environment variable is not set. This is my current setup:

          Are you sure it's working with GitHub PRs? I saw some comments online that it's only working with BitBucket.

          marcinl Marcin L added a comment - I checked and $CHANGE_BRANCH environment variable is not set. This is my current setup: Are you sure it's working with GitHub PRs? I saw some comments online that it's only working with BitBucket.
          trusktr Joe Pea added a comment -

          Hello, how can we use the original branch for pull request builds, instead of the PR-XXX branches?

          trusktr Joe Pea added a comment - Hello, how can we use the original branch for pull request builds, instead of the PR-XXX branches?
          trusktr Joe Pea added a comment -

          Figured it out. I set the `Discover branches Strategy` to `only branches that are filed as PRs`, and removed the `discover pull requests` options. Now it builds straight from my pull request branches, exactly like I wanted.

          trusktr Joe Pea added a comment - Figured it out. I set the `Discover branches Strategy` to `only branches that are filed as PRs`, and removed the `discover pull requests` options. Now it builds straight from my pull request branches, exactly like I wanted.

          People

            Unassigned Unassigned
            pkozikow Paweł Kozikowski
            Votes:
            4 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: