Pull Request hash as Bamboo variable

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Duplicate
    • None
    • Component/s: Pull Requests
    • None

      Problem Definition

      There is currently no variable for pull request hashes.

      Suggested Solution

      Add a Bamboo variable, such as ${bamboo.repository.pullRequest}

      Workaround

      As a workaround, you can use your version control system's API. Below are examples of possible GitHub and Bitbucket Server API calls.

      GitHub

      API call
      curl -s -u<username>:<personal-access-token> https://api.github.com/repos/<owner>/<repository>/pulls | grep merge_commit_sha|awk -F'"' '{print $4}'

      Bitbucket Server

      API call
      curl -s -u<username>:<pasword> "<bitbucket-url>/rest/api/1.0/projects/<project-key>/repos/<repo-slug>/pull-requests"|json_pp|grep 'latestCommit\|Ref'
      Enter host password for user 'ezeidan':
               "toRef" : {
                  "latestCommit" : "9f99052b726d18a3c8d62ba9e02f0d09519bedfa",
               "fromRef" : {
                  "latestCommit" : "92006c7ce897a0fb4d8faacd7a0d79d887728925",
      

            Assignee:
            Unassigned
            Reporter:
            Ellie Z
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: