Documentation for Crucible 3.0.x. Documentation for other versions is available too.

You can use the Review CLI tool to create reviews in Crucible, for patches and commits, directly from your terminal. It takes the uncommitted changes in your workspace and creates a review for them in Crucible. The Review CLI tool may be especially useful if:

  • you often create pre-commit reviews
  • you want to submit a diff from an external tool for review

You can use the tool on Windows, Linux and Mac OS X, for repositories that are managed in:

  • Subversion
  • Perforce
  • Git
  • Mercurial
  • CVS

The tool supports Crucible 3.0, and later versions. Python 2.7 must be installed on your local machine (Python 3 is not supported).

You can use the tool to create new reviews, and to update existing reviews with new patches.

Known limitations
  • The CLI tool does not yet allow you to create a review for an existing commit.
  • The CLI tool takes all the files that have been modified, added or removed in the working copy and submits those for review. It doesn't support choosing only files associated with a specific changeset.
  • You can only use the CLI tool to create reviews in projects for which you already have review create permission.

On this page:

Installing the Review CLI tool

Download the Review CLI tool from either of the following locations in Crucible:

  • When creating a review, click Pre-commit in the 'Add Content to Review' dialog, then click Download review CLI tool:


     
  • Choose Settings from your user menu, and then the Tools tab of your user 'Settings' page. Click Download review CLI tool:


     

The script comes pre-configured for the user for the given SCM server.

Copy the script to a location somewhere in your system path, for greatest ease of use.

Python

Python 2.7 is required.

Linux

Python 2.7 should come with your distribution. If not, or if 2.7 isn’t installed, you will need to install the appropriate package. Please refer to your package manager for the appropriate version.

Windows

You can install Python by running the latest Python 2.7 Installer for Windows.

MacOS X

Python 2.7 should come with any modern version of MacOS X. You can also download Python 2.7 from http://www.python.org/getit/.

Using the Review CLI tool

To create a review using the Review CLI tool, run the script from a directory under SCM control that has local, uncommitted changes. The changes will be submitted to Crucible for review.

Call the script with the following command:

crucible.py <arguments list>

The Review CLI syntax is consistent with that for Crucible and FishEye smart commits. Examples of syntax usage are provided in the following table:

Action
Syntax
Result
View usage helpcrucible.py --helpDisplays the help with descriptions of all the valid commandline arguments
Create a pre-commit review interactivelycrucible.pyGets the patch from the current SCM, prompts for the project and review title, and creates a draft review
Create a pre-commit review with a given project and titlecrucible.py -m "the review title" CR-FEGets the patch from the current SCM, creates a draft review in the CR-FE project with the given title
Create a pre-commit review with moderator and reviewerscrucible.py CR-FE @matt @joe --moderator tedGets the patch from the current SCM, creates a review in the CR-FE project, adds matt and joe as the reviewers and ted as a moderator, starts the review
Create a pre-commit review anchored to a specific repositorycrucible.py -r repo1Creates a pre-commit review interactively, trying to anchor the patch to the given repository
Add a patch to a reviewcrucible.py CR-FE-1204Gets the patch from the current SCM and adds it to the review CR-FE-1204
Create a review from diff outputhg diff | crucible.pyCreates a pre-commit review interactively, taking the output of the first command as a patch
Create a review from a diff filecrucible.py -f file.diffCreates a pre-commit review interactively, taking the output of the patch from the given file
  • No labels

6 Comments

  1. I'm having trouble understanding using this with Perforce.  

    1. For newly added files in my change list, when crucible.py posts to the server.  On the server, it only shows the first line of the new file.  Expected: The entire new file. 
    2. If i have two pending changelist (ie CLN 1234 and default CL), how do I choose which changelist to post?  It seems crucible.py posts both changelists with all the files.  
    1. The way the tool works currently it takes all the files that were modified, added or removed in the working copy and submits those for a review. It doesn't support choosing only files associated with a specific Perforce changelist. Please submit a feature request for this.

      For a newly added file the whole file should be submitted for a review, as you expect. Please create a support reqest so that we can investigate further. Please provide the following in the request: the Python and os version, the file that fails to upload, and the debug output of running crucible.py (add -d to the command line).

  2. Thanks for commenting Lukasz Pater.  I've created a feature request for item #1:  FE-4686 - Getting issue details... STATUS .  I'll follow up with support on the second item.  

  3. Thanks for your support Lukasz!

    For those interested in the fix for Perforce added files see:  CRUC-6504 - Getting issue details... STATUS  

  4. Anonymous

    Is  crucible.py meant to be usable on installations where LDAP authentication has been used to provide single sign on?  I get an authentication error of the form below:

    DEBUG:root:No authtoken, trying to get one
    DEBUG:root:Trying to encode str as UTF-8

    DEBUG:root:RestRequest: http://<SERVER:PORT>/rest-service/auth-v1/login - {'Content-Type': 'application/x-www-for
    m-urlencoded', 'Authorization': ('Basic XXXXXXXXXXXXXXXXXXX',), 'Accept': 'application/json'} - userNa
    me=<USERNAME>&password=<PASSWORD>
    DEBUG:root:RestError: HTTP Error 401: Unauthorized

    1. The tool should work fine with LDAP authentication. Please file a support request including both the server and the tool debug logs, so that we can investigate further.