Set up a Jazz Build Engine to run an Ant script: Part 3. Setup build scripts to coordinate code review and build

Learn how to set up an IBM Rational Team Concert main build that performs an IBM Rational Developer for System z code review. Based on the result of the code review, the process either submits the build to compile, or stops and reports the code review errors. Apply the tested, documented sample described in this article to implement a similar solution on your own platform. The steps focus on the Rational Team Concert administrator who writes an Ant task to compile COBOL programs, depending on other previous tasks, such as quality control. Part 3 describes how to run the RPP synchronize task, how to implement a code review, how to parse, convert, and publish the code review results, and how to run the build.

Corinne Blanchard (blanchard_c@fr.ibm.com), Rational client technical professional, IBM

Author1 photoCorinne Blanchard has 20 years of experience in the application development field (Cobol, Pacbase, J2EE). In the last six years she has worked for IBM on Rational products as a client technical professional and team leader for Rational Enterprise Modernization tools. In 2010, she contributed to the IBM Redbooks IBM WebSphere RFID handbook: A solution guide and IBM WebSphere RFID handbook: A programming guide. In 2013, she wrote a workbook that explains the basics of IBM Rational Programming Patterns.



18 March 2014

Overview

This series explains how to use IBM® Rational Team Concert™ to perform a code review. Based on the result of the code review, the process either submits the real build to compile, or stops and reports the code review errors.

Part 1 of this article describes the build definitions, the technical and functional context for the sample scenario, and the build engines that support the build definitions. Part 2 introduces an Ant-based build script, build.xml, that defines tasks for the build to run. You need to read Parts 1 and 2 first.

This article, Part 3, describes how to run the RPP synchronize task, how to implement a code review, how to parse, convert, and publish the code review results, and finally, how to run the build.


Review: Description of Ant build script

Part 2 of this article introduces the Ant build script that runs on the Jazz Build Engine and contributes build artifacts back to the Rational Team Concert server.

The format of the Ant script file is XML, where nodes define tasks for the build to run. Usually this script is named build.xml. For more information about how to create a basic Ant build script, consult the Jazz.net article Getting Started with Ant scripts and RTC Build Ant Tasks.

The build.xml script describes the integration of the subordinate build into the specific build process. The process includes the following steps, as shown in Figure 1.

  • Publish the build parameters files as a contribution of the build
  • Run a preview dependency build to identify which COBOL programs have changed since the last build.
  • Publish the buildableFiles.xml as a contribution of the build.
  • Transform this file into a .txt file, readable by the code review treatment.
  • Run a Rational Programming Patterns synchronization (RPP synchronize) to force and update of the Rational Programming Patterns indexes.
  • Parse the synchronize log file to check that it is successful.
  • Run a code review for the limited perimeter (only COBOL programs that have changed since last build).
  • Parse the code review result files to check if a severe error has been detected.
  • Transform the .csv result file into an .html file and publish it as a contribution of the build.
  • If no severe error has been identified, run a subordinate build to compile the limited perimeter.
  • Wait for the end of the subordinate build and reuse the compile build status to achieve the master build.
Figure 1. build.xml schema
Schema explaining Build process

The publish task and the preview build task are covered in Part 2 of this series. This article starts with the RPP synchronize task.


RPP synchronize task

The RPP synchronize task synchronizes an Eclipse workspace with a sandbox that was loaded with a Rational Team Concert build. This step is dedicated to Pacbase applications and can be skipped in a Java or COBOL context.
Snippet of the schema | Entire schema
Figure 2. build.xml: RPP synchronize task
build.xml extract from line 162 to 192

The command used to run the RPP synchronize task is stored in the synch.bat file, as shown in Listing 1.

Listing 1. Contents of synch.bat
rem parameters:
rem  %1   ${team.scm.fetchDestination}
rem  %2   ${outputDir}
rem  %3   ${outputDirRpp}

CD "C:\Program Files\IBM\SDP_90\rpp"
CALL rpp --synchronize --sandbox %1 --data "%2/TEMP" --log "%3/TraceRppSync.log"

In a Rational Programming Patterns context, this step is required to update Rational Programming Patterns internal indexes. In a COBOL context, you can skip this step. For more details about the RPP synchronize task, consult the information center.

If the return code is not equal to zero, the master build has failed.


Code review task

Use the Code Review task to analyze COBOL source code and to check that the code respects selected coding rules.
Snippet of the schema | Entire schema

See the complete node that describes the code review in the build.xml file, as shown in Figure 3.

Figure 3. build.xml: Code review task
build.xml extract from line 195 to 211

The command used to run the code review is stored in the CodeReviewCde.bat file, as shown in Listing 2.

Listing 2. Contents of the CodeReviewCde.bat

Click to see code listing

Listing 2. Contents of the CodeReviewCde.bat

rem parameters:
rem  %1   ${team.scm.fetchDestination}
rem  %2   BUILD_PARAMETERS
rem  %3   ${inputDirCodeReview}/exportUserRules.dat
rem  %4   ${outputDirCodeReview}
rem  %5   ${outputDirPreview}/buildableFiles.txt

CD C:\Program Files\IBM\SDP_90\bin
CALL codereviewbatch -workspace %1/%2 -rulefile %3 -exportdir %4 -directory "%1\BVAP.RES.COB\zOSsrc\pacscreen,%1\BVAP.PRO.COB\zOSsrc\pacprogram" -includefile %5 -debug >"%4/TraceCQ.log"

In this command, the attribute values are defined by files:

  • -rulefile attribute: The file previously exported that contains the quality control rules to be applied
  • -includefile attribute: The TXT file obtained by transforming the buildableFiles.xml generated during preview build task.

For more details about how to use the code review command line, consult the information center.


Parse, convert, and publish the results

The code review task generates a time-stamped folder and a log file, TraceCQ.log.
Snippet of the schema | Entire schema

The TraceCQ.log file is shown in Figure 4.

Figure 4. TraceCQ.log file generated by code review command
Content of file TraceCQ.log

The time stamped folder, as shown in Figure 5, contains several files generated during code review.

Figure 5. Code review time-stamped folder
time stamped folder

As shown in Figure 6, the generated file XML Analysis Results.xml file is of special interest because it contains the list of scanned resources and rules identified for each of them.

Figure 6. XML Analysis Results.xml
Content of file XML Analysis Results.xml

The build.xml file in Figure 7 shows the complete node that describes how the log file is parsed.

Figure 7. build.xml: Parse the code review results
build.xml extract from line 214 to 262

The first time through, the log file is locally loaded. Then it is parsed to find the report link using the phrase :9090/rsar/reports/. If this phrase is not found, the code review is considered to have failed.

Next, a Javascript script extracts the timestamp from this phrase and builds the path where results files are stored.

To reformat the XML Analysis Results.xml file and publish it as a build contribution, use the XLS Transformation in the file report.html to transform the XML file into an HTML file. After the transformation, the HTML file appears similar to Figure 8.

Figure 8. report.html
Contents of file report.html

Use the linkPublisher task, to add a link as a contribution to the master build result. When you submit the master build, the HTML code review results become accessible from the External Links tab of the master build result, as shown in Figure 9.

Figure 9. External Links tab of the master build
Build result for master build, External Links tab

Finally, the CSV Analysis Results.csv file is scanned to find the word SEVERE to determine if severe errors are present. If the word is found, the code review is considered to have failed and the master build is stopped at this point.


Run the build to compile the artifacts

The subordinate build is called a second time to compile the COBOL artifacts that have changed since the last build. The instructions here are for mainframe applications and need to be adapted for a Java context.
Snippet of the schema | Entire schema

Figure 10 shows the build.xml file, which includes the complete node that describes the compile process.

Figure 10. build.xml: compile process
build.xml extract from line 265 to 304

In the waitForTeamBuild task, you retrieve the two properties buildStateProperty and BuildStatusProperty.

Regarding the states to wait for, the build is considered as complete when the status is:

  • COMPLETED: The build completed normally, but might contain errors.
  • CANCELED: The build request is canceled before the build started.
  • INCOMPLETE: The build did not complete normally, for example, it is abandoned.

By default, the property timeout is set to avoid an indefinite wait. For more details about the waitForTeamBuild task, consult the information center.

If the subordinate build status is ERROR, the master build is considered to have failed.


Conclusion

The implementation described in this article is based on a simple division of software treatments driven by an Ant task in an IBM Rational Programming Patterns context.

However, this implementation can be applied to other contexts such as COBOL, C++, or Java programming language. The quality control engine proposes native rules for all those programming languages.


Acknowledgements

The author expresses gratitude to Nicolas Dangeville, Benoit Jaunin, and Tony Chen Zhang Hong for implementing this functionality and to Jean-Yves Baudy, Christian Chalumeau, Hervé Le Bars, Stéphane Leroy, Samira Bataouche, and Vincent Trébuchon for reviewing this article.


Appendix

Figure 11. Entire snippet
RPP synchronize task snippet

Back to top

 

 

Figure 12. RPP synchronize task snippet
RPP synchronize task snippet

Back to RPP synchronize task

 

Figure 13. Code review task snippet
Code review task snippet

Back to Code review task

 

Figure 14. Parse, convert, and publish the results snippet
Parse, convert, and publish the results snippet

Back to parse, convert, and publish the results

 

Figure 15. Run the build to compile artifacts snippet
Run the build to compile artifacts snippet

Back to run the build to compile artifacts


Download

DescriptionNameSize
Code sampleCodeReview.zip32KB

Resources

Learn

Get products and technologies

  • Download Rational Team Concert from Jazz.net and try it free on up to 10 developers for as long as you want (requires registration). If you'd prefer, you can try it in the sandbox instead, without installing it on your own system.
  • Download a free trial version of Rational Programming Patterns.
  • Evaluate IBM software in the way that suits you best: Download it for a trial, try it online, use it in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement service-oriented architecture efficiently.

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=965799
ArticleTitle=Set up a Jazz Build Engine to run an Ant script: Part 3. Setup build scripts to coordinate code review and build
publish-date=03182014