Run prerequisites before building to reduce risk of build failure

Source: Internet
Author: User
Tags cpu usage

Brief introduction

Running a build process based on a defined event, such as a nightly build or on-demand build, is a practice of software development. In a large software build, it may take hours or even days to complete the build. Construction often fails. This is a huge waste of lean management. This is particularly true when running this build in the cloud infrastructure, which calculates costs based on CPU usage in the cloud infrastructure.

Running a prerequisite can reduce the risk of a build failure. In some cases, the build requires an approval process. This may apply to the release version, because if the release version contains unwanted changes, the cost of recovery after the release is often high and adds another unexpected cost. Therefore, before running the main build process, it is best to run the prerequisites to check the validity of the build.

Rational Team Concert Build example settings

Figure 1 shows the sample settings used in this article: an IBM? Rational Team concert? Server and a Jazz? Build Engine (Jbe-engine). Server requests are built through the Apache Ant build definition (ant-build).

Figure 1. The build example settings used in this article

In this example, the Jazz build Engine runs on a Microsoft Windows server. Define the build engine as Jbe-engine. Define the build as Ant-build, which uses Jbe-engine to run the Apache ant build. In this case, there is no source code control for the Build.xml used in the build process in order to keep this explanation as simple as possible.

Running prerequisites in the Rational team concert Ant Build

Rational Team Concert supports a variety of build mechanisms. This article describes the build process using ANT, but this example applies to most supported build processes.

Ant builds have a dependency mechanism. For example, you must generate a. Java class before you create a. jar file. To do this, Java compiles a. java file by creating a. Class class. This article uses this dependency mechanism to run the prerequisites. Listing 1 illustrates the basic building blocks of the Build.xml file used in this example.

Listing 1. Build.xml File building block

<?xml version= "1.0" encoding= "UTF-8"?> <project name= "
buildtest" default= "main" >
    <target Name= "main" depends= "pre-condition" description= "" >
        <echo>
            Main build activities
        </echo >
    </target>
    <target name= "pre-condition" >
        <echo>
            precondition for build
        </echo>
    </target>
</project>

In this case, the pre-condition is evaluated and executed before the main target is entered. When the prerequisite is successfully executed, the primary target is run. Listing 2 is the result of running this build.xml log file from the Rational Team concert build engine.

Listing 2. The build result of the Sample.build.xml file shown in Listing 1

BuildFile: 

C:\BUILDS\build.xml
    
pre-condition:
     [echo] 
     [echo]             precondition for build
     [Echo ] Main: [Echo] [echo]
     main build             activities
     [echo] Build         
    
Successful

To illustrate how it works, add <fail/> tasks, as shown in Listing 3. This tells Ant to end with an error state failure.

Listing 3. Sample Build.xml file failed on prerequisite target

<?xml version= "1.0" 

encoding= "UTF-8"?> <project name=
" 
            Main build Activities
        </ echo>
    </target>
    <target name= "pre-condition" >
        <echo>
            precondition for Build
        </echo>
        <fail/>
    </target>
</project>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.