Summary: This article contains information on how to integrate the Review Assistant code review tool into an MSBuild-based build environment, as well as into CruiseControl.NET (CCNet) and Jenkins by using MSBuild target.
Here you will find all the details you need on Integrating Review Assistant with Continuous Integration Systems.
Why Use Continuous Integration?
If several developers are working on the project, from time to time they need to integrate their changes to the project’s code base. The developers also need to run builds to check if the new or updated code can be built successfully. These builds are called integrated builds. Normally, they are performed with a specified schedule.
It is quite difficult to find errors that occur in integrated builds that are performed occasionally, since the number of code changes introduced between the previous and current builds may be huge. To reduce the number of bugs in integrated builds and to make it easier to find errors, integrated builds should be performed as often as possible. In the best case, builds should be performed right after the source code has been modified and reviewed.
Why Integrate Review Assistant with MSBuild?
MSBuild is a build platform for Microsoft Visual Studio applications. The platform uses XML-based project files that specify the actions to be performed during the build.
Review Assistant can be integrated into an MSBuild project to prevent the situation when unreviewed code is included in the scheduled project build. This may be useful when developers are not paying enough attention or even ignore the code review process. Thus, it is possible to disable the automatic build, if during a specified period of time (for example 16 hours) there have been reviews with the “Rejected” status.
Declaring MSBuild Target in the Project File
Targets are declared in a project file with the Target element. For example, the following XML creates a target named CheckRejectedReviews, which then runs the Review Assistant command line. It will check the reviews and call the Error Task in case of violations.
$(MSBuildProjectDirectory)\ReviewAssistantReport.xml
The following is the sample command that can be used to integrate Review Assistant to the MSBuild project file:
ra reviews /server http://raserver:85 /ReviewAssistant /project "My Project" /xml /login Guest /status ReworkNeeded /ModifiedTill 16h
The command returns all the reviews that keep the Rejected status during a specified period of time.
Now you can call the CheckRejectedReviews target right from the continuous integration system you use.
In case you do not plan to get integrated with any continuous integration system, use the BeforeTargets property that indicates that this target should run before the specified target or targets.
We’ve shown you an example of how you can integrate Review Assistant with MSBuild. Further, we will describe how to call the Target explicitly to integrate Review Assistant with CCNet and Jenkins continuous integration systems.
Using CruiseControl.NET with MSBuild
CruiseControl.NET is an open source automated continuous integration server, which includes an MSBuild Task to integrate MSBuild projects. Above we’ve declared the CheckRejectedReviews MSBuild target. To call the CheckRejectedReviews target under CCNet, add the following task to the CCNet project file:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe MSBuild.xml /noconsolelogger CheckRejectedReviews 60000 Check Review Assistant for rejected reviews.
After this, CCNet will show the fail message if during a specified period of time there have been reviews with the “Rejected” status.
We’ve shown you an example of how you can integrate Review Assistant with CCNet. Now let’s see how to integrate the Review Assistant code review tool into Jenkins by using MSBuild target.
Setting Up Jenkins to Work with MSBuild
We will use the CheckRejectedReviews MSBuild target. Above we’ve described its declaration process. Assume that you have already configured Jenkins to work with MSBuild continuous integration system.
If so, you need to do the following:
- Open the project settings, click Add Build Setup, and then select Build a Visual Studio project or solution using MSBuild.
- In the MSBuild Build File text box, type the path to the MSBuils.xml project file.
- In the Command Line Arguments text boox, add /target:CheckRejectedReviews.
After this, Jenkins will show the warning message if during a specified period of time there have been reviews with the “Rejected” status.
Optionally you can mark the build as unstable rather than stop it. For this, call the Warning task instead of the Error task.
In the project settings, click Advanced, and select If warnings set the build to Unstable.
Conclusion
We’ve gone through each integration to provide you with everything you need to integrate Review Assistant with Continuous Integration Systems – MSBuild, CCNet, and Jenkins. Start using Review Assistant for free today.
[…] article in a series of Integration Review Assistant with Continuous Integration Systems. Read the Integrating Review Assistant with MSBuild article to get an additional information about the integration with continuous integration […]
[…] article in a series of Integration Review Assistant with Continuous Integration Systems. Read the Integrating Review Assistant with MSBuild and Integrating Review Assistant with CCNet articls to get an additional information about the […]
Hello,
you should really look at your casing since MSBUILD is case sensitive when it comes to XML nodes.
anyway, trying this out currently.
Carsten