Jenkins CI Integration¶
Jenkins CI is a popular service for continuous integration, allowing you to run test suites, perform builds, and even deploy to servers in an automated fashion.
Review Board can integrate with Jenkins CI to do test builds of code changes and report the results back as a status update on the review request.
Integration Configuration¶
To configure integration with Jenkins CI, click Add a new configuration on the Integrations page in the Administration UI. You can create multiple configurations of the integration to do builds for each repository which supports Jenkins CI builds.
The Name field can be used to set a name for this particular configuration. This allows you to keep track of which is which in the case where you have multiple Jenkins CI configurations.
If at any point you want to stop triggering builds but do not want to delete the configuration, you can uncheck Enable this integration.
Conditions allows you to set conditions for when Review Board will trigger a build. At a minimum, you should set a condition to match a specific repository. Even if you only have one repository configured now, you’ll want to set this up so things don’t break if you connect a second one. If needed, you can create complex rules for which review requests get matched with this config (for example, if you only want to run a test suite for certain branches).
The Server field should be set to the base URL of your Jenkins CI server.
The Job Name field allows you to specify which job to run on your Jenkins CI server. This field also allows for variables like {repository} and {branch}, which will be auto-populated with the appropriate fields from a review request.
The User field specifies the username for a Jenkins CI user who has the appropriate permissions for starting the above Job name.
Password should be set to the above User’s password.
ReviewBoard API Token specifies the API token to use when configuring your Jenkins CI server.
Jenkins Plugin Installation¶
- On your Jenkins server, navigate to Manage Jenkins, then select Manage Plugins.
- On the plugins page, select the Available tab, then type “Review
Board” into the Filter box. You should see one result (but you
can click the link and verify that the ID listed is
rb
if multiple results appear). - Select the checkbox and click Install without restart.
- Restart your Jenkins server.
Jenkins Configuration¶
To create a Review Board server configuration for your Jenkins server, perform the following steps:
- On your Jenkins server, navigate to Manage Jenkins, then select Configure System.
- Scroll down until you reach the Review Board configuration section.
- Click Add Review Board Server to create a new Review Board server configuration.
- Enter your Review Board server URL into the Review Board URL field. This must match exactly the server URL set in the Review Board General Settings page.
- If you have previously created a credential for your Review Board API token, select it here and skip to the job configuration.
- If you have not yet created a credential for the Review Board API token, click Add and select Jenkins.
- In the prompt, set Kind to Secret text.
- Set Scope to Global.
- Fill in Secret with the Review Board API Token found in the Jenkins CI integration configuration page in the Review Board administration UI.
- Give your secret a unique identifier in the ID field and click Add.
- Click Save to save your server configuration.
For each job you wish to use on Jenkins, you must add four new build parameters that will be used to give Jenkins information on the incoming review request. To add these, perform the following steps:
Navigate to your job’s page and click Configure.
Ensure the This project is parameterized checkbox is checked.
For each of the following parameter names, repeat these two steps:
REVIEWBOARD_REVIEW_ID
REVIEWBOARD_REVIEW_BRANCH
REVIEWBOARD_DIFF_REVISION
REVIEWBOARD_STATUS_UPDATE_ID
REVIEWBOARD_SERVER
- Click Add parameter and select String parameter.
- Input the parameter name into Name and leave all other fields blank.
Scroll down to the Build section. Here we can add the Apply patch from Review Board step by clicking Add build step and choosing it from the dropdown menu.
Note
This step uses RBTools to apply the patch from Review Board. It will attempt to install the package using pip, but if it lacks permission you will need to manually install it. Additionally, the order of your build steps matter, so this step should likely be the first build step so all later build steps see the correct source code.
Scroll down to the Post-build actions section. Here we can add the Publish build status to Review Board step by clicking Add post-build action and choosing it from the dropdown menu.
Click Save to save these changes.