Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to delete draft reviews in a batch?

Blazej Kroll August 13, 2012

I have over 1000 reviews in draft. I need to clean the reviews database in some smart way. How to delete reviews from Crucible??

Is it possible form GUI or do I have to do it on a database?

HOW?

Thanks in advance,

Blazej

4 answers

2 votes
LeonardoL
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.
August 13, 2012

Hi Blazej,

In this case you could delete review using crucible's REST API. Here's an example using curl command line you can try:

curl -u <username>:<password> http://localhost:8060/fisheye/rest-service/reviews-v1/<reviewID> -X DELETE -H "Content-Type:application/xml"

Replace the username, password, host url, reviewID accordingly. You can consult more information about reviews structure at crucible's database inside table cru_review. Also this procedure deletes one review so you can create a script to run it against more that one review to automati the process.
 

Also this procedure delete one review so you can create a script to run

it against more that one review to automati the process.

 
Cheers,
Leonardo.
 

Blazej Kroll August 15, 2012

Hi Leonardo,

Thanks for your answer. I tested the REST API method you mentioned. However, it seems that all the reviews must be put in Abandoned state beforehand. (which was quite an astonishing discovery...)

  • I go the following error while trying to delete a drafted code review:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error><code>IllegalArgument</code>
<message>
The review PermId:CR-5113 in the Draft is not deletable.
</message>

<stacktrace>
java.lang.IllegalArgumentException: The review PermId:CR-5113 in the Draft is not deletable.
        at com.atlassian.crucible.spi.impl.DefaultReviewService.deleteReview(DefaultReviewService.java:1679)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	...
</stacktrace>
</error>

  • I also tried the following method:
    /rest-service/reviews-v1/{id}/transition?action:deleteReview

The description I took from here is inconsitent with way this option should be executed:

/rest-service/reviews-v1/{id}/transition?action=action:deleteReview

I think you should correct the description here.

I found the proper way of doing it here:

curl -k -u login:pass http://myCrucibleHost/rest-service/reviews-v1/CR-5113/transition?action=action:deleteReview -X POST -H "Content-Type:application/xml"

Performing the aciton both ways on an abandoned review works fine:

curl -k -u login:pass http://myCrucibleHost/rest-service/reviews-v1/CR-4894 -X DELETE -H "Content-Type:application/xml"

  • Why you need to change a review to abandoned in order to delete it?
  • What is happening when a review is in an abandoned state?
  • I plan to transform all my drafts (which I want to remove) to abandoned reviews - is there anything I should look for/worry about?

Best regards,

Blazej

Blazej Kroll August 15, 2012

Hi Leonardo,

I am still having issues with this.

As I am trying to change the state of a review to abandoned with:

curl -k -u user:pass "http://myCrucibleHost/rest-service/reviews-v1/CR-2197/transition?action=action:abandonReview" -X POST -H "Content-Type:application/xml"            
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><error>
<code>Authorization</code>
<message>
Crucible unauthorised action.
</message><stacktrace>com.atlassian.crucible.spi.services.AuthorizationException: Crucible unauthorised action.
        at com.cenqua.crucible.model.managers.impl.DefaultReviewManager.changeState(DefaultReviewManager.java:967)
        at com.atlassian.crucible.spi.impl.DefaultReviewService$27.doInTransaction(DefaultReviewService.java:1703)
        at com.atlassian.crucible.spi.impl.DefaultReviewService$27.doInTransaction(DefaultReviewService.java:1694)
        at com.atlassian.fisheye.spi.impl.DefaultTxTemplate.execute(DefaultTxTemplate.java:123)
        at sun.reflect.GeneratedMethodAccessor1236.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)

I am using administrator rights and still get this error.

How to be able to abandon a review??

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
August 15, 2012

Try the Crucible CLI (see other answer) and use -v to see what it is doing under the covers. I remember it being a royal pain for doing something one would think as being simple.

LeonardoL
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.
August 15, 2012

Hi Blazej,

Here's some ideas that could help you:

1. Take a look into this and see a workaround which actually worked.

2. Make sure your users have permission to ABANDON reviews inside Crucible ADMIN at Permission Scheme and then try again.

3. Try to summarize and then delete:

curl -v -d "" -u youruser:pwd -H "Content-Type: application/xml" http://myCrucible/crucible/rest-service/reviews-v1/CR-2197/transition?action=action:summarizeReview
curl -v -d "" -u youruser:pwd -H "Content-Type: application/xml" http://myCrucible/crucible/rest-service/reviews-v1/CR-2197/transition?action=action:closeReview

1 vote
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
August 13, 2012

deleteReview action from the Crucible Command Line Interface can be used in combination with runFromSql to select the reviews you want to remove from the Crucible database. The deleteReview action makes sure the review is in the appropriate state to delete before running the delete (under the covers, the delete is done using the rest api like in Leonardo's answer).

0 votes
Malik
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 12, 2012
0 votes
LeonardoL
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.
August 13, 2012

Hi Blazej,

It's possible to delete reviews from GUI. Please refer to this article to know how. I hope this can help you.

Cheers,

Leonardo.

Blazej Kroll August 13, 2012

Hi Leonardo,


Thanks for quick answer - I knew about that option, however I'd like to make a massive delete of over one thousand reviews in draft mode. I really don't like to do it on a one-by-one basis.

How to delete all draft reviews with single operation? sql query? script?

Regards,

Blazej

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events