Integrate the Mercurial version control tool with IBM Rational Build Forge

Steps and sample code for creating an adapter

From this article, you will learn how to write an adaptor to integrate the Mercurial distributed version control tool with IBM® Rational® Build Forge® build and release management software, how to parse and extract the detail information into the Bill of Materials, or BOM, and how to determine whether there are new changesets coming.

Share:

Fan Hu (fanhu@au1.ibm.com), Senior Consultant, IBM

Author1 photoFan Hu is a senior consultant for Australian Lab Services, IBM Software Group, with a focus on Rational Build Forge and the IBM Rational Automation Framework for WebSphere software. He has rich experience in build automation.



30 August 2011

What you need to know and do before you start

From this article, you will learn how to write an adaptor to integrate the Mercurial distributed version control tool with IBM® Rational® Build Forge® build and release management software, how to parse and extract the detail information into the Bill of Materials, or BOM, and how to determine whether there are new changesets coming.

Prerequisites

  • For this purpose, we assume that the agent, which will run the adaptor, is running in a Linux or UNIX environment, because you need some command of Linux or UNIX to parse the command.
  • You have made a clone in the server where the Rational Build Forge agent is running

Objective of this example

Using this example, you can get a quick start in integrating Mercurial with Build Forge. And using this example as a template, you can add more features based on it.

This example will connect a project by using a project name, which is passed in as an environment variable and checked if there are new changesets coming. If there are new changesets coming, the adaptor will download them from repository. If there are not, the adaptor will set the flag to "FAILED." It is easy to create a continuous build based on this adaptor.

Environment variables

Table: Variables used in this adaptor example
VariableVariable meaningExample
projects_root The root directory for projects of your Mercurial local clone projects_root=/code/mercurial/projects
project Your project name under whatever you named the projects_root project=testProjectOne
This means that your project is located in:
/code/mercurial/projects/testProjectOne

Use the example

Here is the procedure to use the example:

  1. Download the example code from the Downloads section of this article.
  2. Create an adaptor using this example code, and give it a name, for example MyMercurialAdaptor,
  3. Create a test project.
  4. Integrate the adaptor in either of these two ways:
    1. Use the Create an adaptor link to link the project with the adaptor.
    2. Use the .source command in a step, for example:
      .source MyMercurialAdaptor
  5. Run the project.
    Note:If you are using the adaptor link, don't forget to click the check box for Use adaptor link.

Output of the adaptor

In the adaptor, there are two steps.

  1. Use the hg in command to check whether there is any new changeset coming.
  2. Use the hg pull/hg update command to pull and update the changeset on the local server.

If there is no changeset coming, the adaptor will return "FAIL," but if there is new changeset coming, it will pull and update it. If successful, the adaptor will return a "Successful" response code. If it encounters any problem, it returns "FAIL" code.

After running, the changeset details (such as file name list, author, change date, and description) will be recorded in the Bill of Materials, or BOM.


Download

DescriptionNameSize
Simple ProjectmecurialAdaptor.zip1KB

Resources

Learn

Get products and technologies

  • Check the Trials and Demos page for Rational software.
  • 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=754665
ArticleTitle=Integrate the Mercurial version control tool with IBM Rational Build Forge
publish-date=08302011