Retrieve Crucible project from JIRA issue using the Rest Api

elhmarouan April 17, 2015

I'm developping a C# Rest client for JIRA and Crucible which can perform creating reviews for an issue, i found that is annoying to specify Crucible's project key each time i want to create a review. I tried Project Links between Crucible and JIRA but i could'nt extract this information from Rest.

I would be pleased if someone could become by any help about this.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
gustavo_refosco
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

Hi Marouan,

JIRA Rest API doesn't offer a way to create reviews from JIRA issues, so this need to be done entirely in Crucible side. I did some research to try putting together all the steps I think that are necessary for this, trying to create reviews in a way similar to what is done via UI from a JIRA issue, i.e. creating a review linked to a JIRA issue and containing the revisions/commits linked to that issue.


Get a list of changesets associated with the JIRA issue

You need to get a list of the changesets linked to the JIRA issue for which you are going to create the review. There is no function to automatically get the issues for a changeset, so we are going to search for those changesets containing the JIRA issue key in its commit message. Based on this Answers topic you can do this using the FishEye Rest API either:

  • Listing the changesets containing the issue key in their comment, then taking the csid from them:
<Crucible_URL>/rest-service-fe/changeset-v1/listChangesets?rep=<repo_name>&comment=<issue_key>&expand=changesets
  • Using an EyeQL query looking for revisions with comments matching the issue key:
<Crucible_URL>/api/rest/query?rep=<repo_name>&query=select%20revisions%20from%20dir%20%22/%22%20where%20comment%20matches%20%22<issue_key>%22


Create the Review


Create a review using the Reviews Crucible REST API using the POST method. Under the acceptable request representations for this function you will see you can link it to the jira issue setting the jiraIssueKey, and defining the changesets to be added under changesets, among other options.

Regards,
Gustavo Refosco

elhmarouan April 19, 2015

Thanks Gustavo for your answer, Sorry for disturbing but I could'nt find Fisheye/Crucible project key from the list of changesets, i think it is necessary to create the review...

elhmarouan April 19, 2015

I precise also that I am doing Pre-commit Reviews, so I add diffs when i create reviews instead of changesets...

gustavo_refosco
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 20, 2015

Hi Marouan, THe function I provided means to check all the changesets you have associated with a JIRA issue - the association you gets when you perform a smart commit to link a changeset to a JIRA issue. The project key from Crucible will be hardcoded in the function used to create the review, i.e. I expect you already know in which project you want to create the Review, and also for which JIRA issue, just needing to know what changesets to put in this review. Either way, as you mentioned you are doing pre-commit reviews, I wonder if you have actually any changeset linked to a JIRA issue. If you actually don't have anything linked to the JIRA issue in question, then I think your process would be of just using the function to create the review in Crucible side, as it allows you to specify the Crucible project in which the review project will be created, as well as the JIRA issue you want to link the review to. Regards, Gustavo Refosco

TAGS
AUG Leaders

Atlassian Community Events