Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Git branch name through Crucible REST API

Hello, colleagues! I'm trying to fetch list of completed reviews with REST API - it's simple sure, but I need to extract:

  1. name of related Git branch
  2. author's emails

With 2nd i can use "users-v1" API endpoint, but not all users have emails there. But with 1st I have big problem - I can not find way to extract Git branch name! Is there any way to find Git branch name? As I understand, Crucible has this info - files were submitted, review was completed, branch is known... But how to get it from REST API of Crucible? (I use Crucible + FishEye service).

I tryed different API calls, found in documentation field "ahcnorName" - it looks like branch name, but when I try to call repositories' related endpoints with existing repositories, I get error that repository not found... 

Can somebody show an example of call/point out REST call - how to get Git branch name related to completed review?

1 answer

1 vote

Are you using branch reviews to run the reviews?  If so, you can try using undocumented REST API to retrieve the list of all the branches tracked in particular review.  Issue a GET request to http://<CRUCIBLE_URL>/rest/branchreview/latest/trackedbranch/<REVIEW_KEY> to get document like:

"id": "<HASH>",
"repositoryName": "repositoryName",
"repositoryDisplayName": "repository display name",
"repositoryType": "git",
"reviewedBranch": "some-feature-branch",
"baseBranch": "master",
"autoUpdate": false,
"lastChangesetId": "<HASH>"

If you are not using branch reviews but are adding content to review differently (e.g. by picking up individual changesets, files, etc.) I'm afraid it might be a challenge to identify what branch those changes come from.   git doesn't really track the branch changeset was created on.

Hope that helps,  

Hello, Piotr. It seems I also found this:


Both params I know from:

https://HOST/rest-service/reviews-v1/REVIEW-PERMA-ID/details. But with this way I have another questions:

  1. 2nd call returns a list in repositoryName JSON field, length=1. Is it 1 a fixed length? Is it correct to get 1st item always?
  2. I get GIT-HASH as toRevision field from 2nd call's response JSON. But there is also field fromRevision. Do I need toRevision actually?
  3. 1nd call's response contains branch and also list of branches. Do I need this scalar field branch only (and should ignore list of branches)?
  4. Will this method work for all kind of reviews (with diff-files) ?


Best regards


re 1. repositoryName is returned for each individual reviewItem (file on the review), so yes, it's always scalar value, as single file is coming from at most 1 repository. repositoryName might be missing for uploaded files or patches though, so I wouldn't assume it's always there.

re 2. fromRevision and toRevision indicate versions presented on revision slider, top of the review file. Depending of what you want to achieve you might be interested in one of those fields or both

re 3. again, this depends what data you are after. Remember git doesn't store information what branch particular commit was made on, this is dynamic and relation between particular changeset and branches may change over the time, where more branches are created or merged and their ancestry start to contain particular changeset.

Thank you, Piotr!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

190 views 0 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you