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 Join to answer
Community showcase
Alexey Matveev
Published Saturday in Jira

How to run Jira in a docker container

Everything below is tested on Ubuntu 17.10. I prefer to use Jira in a docker container because: 1. I can install Jira with a couple of commands. 2. I can start and stop Jira just by starting and s...

255 views 6 8
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot