Adding a checklist to new Reviews

Top  Previous  Next

In this tutorial we will set up a script that will automatically add a checklist to every new Review immediately after it is created.

Outline

When a Review is created in Code Collaborator the Review created trigger invokes the Code Collaborator Command Line Client to add a checklist to the Review.

Prerequisites

The trigger invokes the Code Collaborator Command Line Client, so that needs to be installed on your server machine.  Be sure to install the Command Line Client so that it is accessible and executable by the system user which is running the Code Collaborator server (this is especially important on Unix systems).

Step 1: Save your checklist on the server

Create your checklist and save it somewhere on the machine which is running your Code Collaborator server.  The checklist needs to be accessible by the system user which is running the Code Collaborator server (this is especially important on Unix systems).  In this tutorial we'll refer to the checklist as "C:\Program Files\Code Collaborator Server\checklist.txt".

 

Step 2: Set up the Command Line Client's connection to the server

Log in to your server machine as the user which is running the Code Collaborator server.  Run the Command Line Client with this command:

ccollab login

 

The login command will prompt you to establish the connection to the server (url, username, password, etc...).  It's important that the Code Collaborator user account that you use is a Code Collaborator Administrator, so that the Command Line Client will be allowed to upload the checklist to any Review.  When the connection is successful the Command Line Client will save the connection settings to a config file (encrypting the password).

To make sure everything is configured correctly run this command:

ccollab info

 

You should see output similar to this:

Connecting to Code Collaborator Server http://collab.example.com

Connected as: Collaborator Administrator (admin)

SCM system is configured to Auto-detect

Auto-detecting SCM System for 'C:\'..

No SCM system detected

 

Step 3: Test adding a checklist from the command-line

Before you configure the Code Collaborator server to add the checklist automatically, test it manually by opening a console on your server machine and running the Command Line Client. Be sure to log in to your server machine as the system user which is running the Code Collaborator server.  First create a Review (let's say it's Review ID is 1234) and then run:

"C:\Program Files\Code Collaborator Client\ccollab.exe" --non-interactive --no-browser addfiles 1234 "C:\Program Files\Code Collaborator Server\checklist.txt"

 

You should see output similar to this:

Connecting to Code Collaborator Server http://collab.example.com

Connected as: Collaborator Administrator (admin)

Loading review ID 1234

Attaching files to review

Checking that you are allowed to upload files to this review

Getting SCM information for files

Auto-detecting SCM System for 'C:\Program Files\Code Collaborator Server\checklist.txt'

Could not determine SCM system for file 'C:\Program Files\Code Collaborator Server\checklist.txt' - uploading as unmanaged file

Sending file contents to Code Collaborator server

Uploading Changelist to Code Collaborator server

Uploading C:\Program Files\Code Collaborator Server\checklist.txt

Local changes successfully attached to Review #1234: "test review for adding checklist"

 

When you refresh your browser in Code Collaborator you should see the checklist has been added to the Review.

 

Step 4: Invoke the Command Line Client from a trigger

Make sure you have Step 3 working before you move on to this step.  The last thing we need to do is tell the Code Collaborator server to automatically invoke the ccollab addfiles command when a Review is created.  We do this with the Review created trigger.  We will use these values:

Executable: C:\Program Files\Code Collaborator Client\ccollab.exe

Parameters: --non-interactive --no-browser addfiles "$review.id" "C:\Program Files\Code Collaborator Server\checklist.txt"

Review Created Trigger

Review Created Trigger

Note that it is important to use the FULL PATH of both the Command Line Client and the checklist.  Arguments that may have spaces in then must be surrounded by quotes.  The Review id comes from a substitution variable.

Finished

That's it!  Now when anyone creates a Review in Code Collaborator the checklist will be added automatically.  Note that for performance reasons the trigger runs after the Review is created in a separate thread, so you may have to refresh your browser a couple of seconds after creating the Review to see the checklist automatically added.