Set up a Jazz Build Engine to run an Ant script: Part 2. Setup build scripts to perform preview 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 2 introduces the Ant-based build script, build.xml, that defines tasks for the build to run.

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

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. You need to read Part 1 first.

This article, part 2, introduces an Ant-based build script, build.xml, that defines tasks for the build to run.

Description of the Ant build script

The master build drives the different tasks to be submitted. The master build uses an Ant build script that runs on the Jazz Build Engine. This script also 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 to force an 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 is detected.
  • Transform the .csv result file into an .html file and publish it as a contribution of the build.
  • If no severe error is 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

See the following descriptions of each node of the build.xml file.


Publish script files task

The purpose of this first step is to publish as a build contribution, the main scripts and files that are used by the Ant script.
Snippet of the schema | Entire schema

The scripts or files are stored in the Rational Team Concert component BUILD_PARAMETERS, as shown in Figure 2.

Figure 2. BUILD_PARAMETERS component
Structure of the Rational Team Concert component

Define the following four scripts or files as a contribution:

  • build.xml: Ant build description, as shown in Figure 3
  • codeReviewCde.bat: Command line for code review
  • synch.bat: Command line for RPP synchronize
  • buildPreview.properties: Override properties for preview build

With the artifactFilePublisher task, the selected artifacts are stored directly in the Jazz repository.

Figure 3. build.xml: Publish task
build.xml extract from line 37 to 84

For more details about the artifactFilePublisher task, consult the Rational Team Concert information center.

When you submit the master build, those artifacts become visible from the Downloads tab of the master build result, as shown in Figure 4.

Figure 4. Downloads tab of the master build
build result for master build, downloads tab

Preview build task

The IBM Rational Team Concert preview build allows you to see what will be built, without running a real build. This feature is available only for dependency builds.
Snippet of the schema | Entire schema

As shown in Figure 5, the first part of the node in the build.xml file describes the preview build.

Figure 5. build.xml file: Preview build task
build.xml extract from line 87-133

To configure a preview build, override the build property team.enterprise.build.dependency.previewBuild. To set this property to true, first create a property file, as shown in Listing 1.

Listing 1. Property file buildPreview.properties
# those properties will override the build properties
team.enterprise.build.dependency.previewBuild=true

Next, notify the build task to use this property file in the requestTeamBuild task by using the overridePropertiesFile attribute, as shown in Figure 6.

Figure 6. overridePropertiesFile attribute in the requestTeamBuild task
build.xml extract from line 98 to 104

All the files resulting from this build are available in the Downloads tab of the subordinate build, as shown in Figure 7. This example shows manual creation of the properties file. However, in an enterprise situation, you might use an Ant task to create the file, which increases the reliability of the parameters that are used across the organization. For more information about how to create a file using an Ant task, consult the Ant Apache manual.

Figure 7. Downloads tab of the subordinate build
Build result for subordinate build, Downloads tab

In the preview build, add a linkPublisher task, as shown in Figure 8. This task adds a link as a contribution to the master build result.

Figure 8. linkPublisher task
build.xml extract from line 106 to 113

For more details about the linkPublisher task, consult the information center.

When you submit the master build, the subordinate 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

Publish buildable files task

The generated file buildableFiles.xml is of special interest because it contains the artifacts list of what has been modified since the last build. The modified parts need to be rebuilt.
Snippet of the schema | Entire schema

Figure 10 shows the relevant section of the buildableFiles.xml file.

Figure 10. buildableFiles.xml
Content of file buildableFiles.xml

Click to see larger image

Figure 10. buildableFiles.xml

Content of file buildableFiles.xml

You can consult this file from the Download tab of the subordinate build, but it's ideal to be able to access to it from the master build.

To retrieve this file locally, copy it into a local working directory and publish it as an artifact in the master build.

The build.xml file is second part of the node that describes the preview build, as shown in Figure 11.

Figure 11. build.xml file: Copy buildableFiles.xml locally
build.xml extract from line 135 to 151

For more details about the artifactLinkPublisher task, consult the information center.

When you submit the master build, this artifact becomes visible from the Downloads tab of the master build result, as shown in Figure 12.

Figure 12. Downloads tab of the master build
Build result for master build, Downloads tab

Retrieve and convert the generated results task

To be able to reuse this file as an input of the code review task, you need to extract the name of the COBOL source files. Use the XLS transformation in the file build.xml to transform this XML file into a TXT file.
Snippet of the schema | Entire schema

The file has been retrieved in the previous step. The next step is to transform the file as shown in Figure 13.

Figure 13. build.xml : Convert results to TXT file
build.xml extract from line 153 to 159

After the transformation, this file appears similar to what is shown in Figure 14.

Figure 14. buildableFiles.txt
Content of file buildableFiles.txt

This TXT file can now be used as an input for code review.

Part 3 of this series 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.


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 15. build.xml schema
Schema explaining Build process
Figure 16. Publish task snippet
Schema explaining Build process

Back to top

 

 

Figure 17. Code review, Parse convert and publish, Run the build snippet
Schema explaining Build process

Back to Preview build task

Back to Publish buildable files task

Back to Retrieve and convert the generated results task

 


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=965764
ArticleTitle=Set up a Jazz Build Engine to run an Ant script: Part 2. Setup build scripts to perform preview build
publish-date=03182014