Learning objectives
In this tutorial, you learn how to complete these tasks:
- Create a Git repository from which your project downloads the source for JUnit.
- Create a build process and associate an agent pool to it.
- Create a job that checks-out the JUnit source from GitHub and uses Maven to build JUnit, and run tests and generate test reports.
- Create templates that define properties. You supply values for these properties when you create the project.
- Create a project that is based on the templates you created.
- Run a build and monitor its progress.
- Examine build details and troubleshoot problems.
System requirements
To run this tutorial, you need the following resources:
- An installation of IBM® UrbanCode™ Build, version 6.1 or later.
- An IBM UrbanCode Build agent installed.
- An installation of Maven on the computer where the agent is installed.
Prerequisites
To complete this tutorial, you must have an account on the server with permissions to create and edit projects, jobs, and repositories, and to create and run processes.
- Configure the tutorial system
To run the tutorial project, you must configure an agent, install the required plug-ins, and create an artifact set.
- Lesson 1: Create a Git repository
Repository integrations enable IBM UrbanCode Build to checkout code, access change logs, and do other project-related activities.
- Lesson 2: Creating a job and adding steps
A job is a series of steps that, taken together, complete some activity, such as building a project. The steps are run one at a time in the order you specify.
- Lesson 3: Creating a project template
Projects manage builds, dependencies, and artifacts. A project template is a reusable blueprint that defines a generic project.
- Lesson 4: Creating a source template
A source template is a reusable source configuration that can be used by any project that requires the same source type.
- Lesson 5: Creating a process template
Build a process template for the tutorial project.
- Lesson 6: Creating a project
You use projects to configure and run builds. After a build runs, projects provide a wealth of information that you can use to manage the project lifecycle and troubleshoot problems.
- Lesson 7: Running the build
Run the project build process to transform the source code into the finished application, JUnit.
Configure the tutorial system
About this task
To complete the tutorial, you must have an agent that is running on a target computer. An agent is a lightweight process that runs on a target computer and does the actual work of building the project. This target computer can be a virtual image, or a physical computer, including the one where the server is installed. You must have access to this computer and be able to install the agent on it.
To prepare the tutorial system:
Procedure
- Prepare a computer for use as the target system. This computer must meet the system requirements that are listed in System requirements.
- Install the plug-ins used in the tutorial. The tutorial uses the following plug-ins: Git, Maven, and JUnit. The Maven plug-in is installed with the product. Download and install the Git and JUnit plug-ins. Plug-ins can be downloaded from the IBM® UrbanCode™ Buildplug-in site: https://developer.ibm.com/urbancode/plugins/ibm-urbancode-build/. For information about installing plug-ins,
- Install an agent on the target computer. For performance reasons, agents are generally not installed on the same computer where the IBM UrbanCode Build server is located. For the tutorial, installing the agent on the computer where the server is located is fine.
- Configure the agent. Your agent must be included in the list of configured agents on the Agents page with a status of Online.
- Create an agent pool and add the installed agent to it.
- Install the open source tools Git and Maven on the computer where the IBM UrbanCode Build agent is located. Add the home directory for each tool to the PATH variable on the target system. Add the MAVEN_HOME variable to the PATH variable.
- Ensure that the artifact set included with the product, maven, is available. If it is not installed, create the artifact set by completing these steps:
- From the IBM UrbanCode Build dashboard, click System, then click Artifact Sets.
- In the Artifact Sets page, click Create New.
- In the New Artifact Set dialog box, in the Name field, type maven.
- Click Save.
- Optional: Configure Java™. The agent that runs the tutorial project must be configured to use a Java JDK instance, and not a JRE. If the agent is configured to use a JRE (identified by the agent's java.home property), reconfigure the agent to point to a JDK. Alternately, you can add the JDK_HOME property to the installed.properties file, which is in the agent_installation/conf/agent directory. In addition, the tutorial's Maven Build step must reference that property with the JAVA_HOME setting.
Lesson 1: Create a Git repository
Procedure
- On the IBM UrbanCode Build dashboard, click System > Repositories.
- Using the Repositories page, click Create Repository.
- In the Source Plug-in list, select Git and then click Set.
- In the Name field, type demoHub.
- In the Repository Base URL field, type https://github.com/junit-team. This GitHub project contains the JUnit source code.
- Click Save.
Lesson 2: Creating a job and adding steps
Creating a job
Most job steps are created from plug-ins. Plug-in steps can be thought of as distinct pieces of automation.
About this task
By combining steps from various plug-ins, you can create fully automated build processes. The number of steps that are provided by a particular plug-in can vary, and each step has a variable number of properties. Property values can be supplied when you define a step or at process run time.
Create a job by completing the following steps:
Procedure
- On the IBM UrbanCode Build dashboard, click Templates > Jobs.
- On the Jobs page, click Create.
- In the Create a Job window, specify the name to be Demo Job.
- Click Save. The Main tab for the new job is displayed.
Results
Use the Main tab to add steps to the job. Except for the first step, steps can be inserted before or after other steps. When you run the job, the steps are run in the order you specify.
Creating a stamp step
A stamp is a custom identifier that is applied to a build. Stamps are often used in addition to the automatically generated build life identifiers. A stamp step is part of most jobs.
Procedure
- If the Main tab for the Demo Job is not displayed, then from the IBM UrbanCode Build dashboard, click Templates > Jobs, and then click Demo Job.
- Click Create Step.
- Using the Steps dialog, click Build. The Build list expands to display the available build-type steps and plug-ins.
- Click Create Stamp step, and then click Select. The Stamp dialog is displayed. The dialog that is displayed after selecting a step contains properties for the selected step, and other properties common to all steps.
- In the Name field, type Create Stamp.
- In the Stamp field, enter a script to define the stamp: 1.0.0.${p:buildlife/id}. The simplest way to make a unique stamp is to associate it with the build-life number. This short script looks-up the current build-life ID and applies it to the stamp. This script references a property that is part of every build life. Another option might be to reference a property that you can create and define later. For the tutorial, the build life property is fine. For information about the available properties, see the Scripting API Reference server_url/tools/scripting/ibm-ucb-scripting/.
- Click Save.
Cleaning the workspace
Procedure
- Click the Insert After action for the Create stamp step. After a job has its first step, steps are inserted before or after other steps. The Insert After action, as the name implies, inserts the new step after the selected step.
- On the Steps dialog, click Source and then click Clean Workspace.
- Click Select. The Clean Workspace step is selected.
- In the Name field, type Clean.
- Click Save.
Populating the workspace
This step places the checked-out code (defined later in the project's source configuration) in the agent's workspace.
Procedure
- Use the Insert After action for the Clean step.
- On the Steps dialog, click Source and then click Populate Workspace.
- Click Select.
- In the Name field, type Populate.
- Click Save.
Creating a get changelog step
This step retrieves source changes since the last build. The prior build life is located by using status or stamp parameters.
Procedure
- Click the Insert After action for the Populate step.
- On the Steps dialog, click Source and then click Get Source Changes.
- Click Select.
- In the Name field, type Get Changelog.
- Select Success on the Start Status list. The value that is selected determines which source items are retrieved. In this case, only items with a value of Success are retrieved.
- Ensure that Save Changes in Database is selected (it is by default). This parameter can be used in build reports.
- Click Save.
Creating the set version step
Create a version ID that Maven can use.
Procedure
- Click the Insert After action for the Get Changelog step.
- On the Steps dialog, click Build > Build Tools > Maven, and then click Maven Build.
- In the Name field, type Set Version.
- Ensure that the default value pom.xml is set in the Maven POM File field. Maven uses the project object model file (POM) to control builds.
- In the Goals field, type versions:set. Goals are similar to Ant tasks and define the actions that Maven performs.
- Optional: If you did not put the Maven home variable on your system PATH variable, enter it in the Maven Home field.
- In the Properties field, type newVersion=${p:buildlife/latestStamp}.
- Click Save.
Creating the Maven build step
This step uses Maven to build the project.
Procedure
- Click the Insert After action for the Set Version step.
- On the Steps dialog, click Build > Build Tools > Maven, and then click Maven Build. This step uses the same plug-in step as the previous step, Set Version.
- In the Name field, type Maven Build.
- Ensure that the default value pom.xml is set in the Maven POM File field.
- In the Goals field, type ${p:maven.goals}. Unlike the other properties you used in the job, this value references a new property. Later, you create the property and define the value.
- Optional: If you did not put the Maven home variable on your system PATH variable, enter it in the Maven Home field.
- Click Save.
Creating the publish unit tests step
JUnit is a testing framework for Java™. This step runs tests and reports the results. It is configured to always run.
Before you begin
Before you begin this lesson, make sure that you complete the steps that are described in Configure the tutorial system.
Procedure
- Click the Insert After action for the Maven Build step.
- On the Steps dialog, click Quality > Unit Testing > JUnit, and then click JUnit Report.
- In the Name field, type Publish Unit Tests.
- In the Report Name field, type JUnit Report.
- In the Source Directory field, type target/surefire-reports.
- In the Include Patterns field, type TEST*.xml.
- Display the Pre-Condition Script list by clicking Show Additional Options, and then select Always. Unlike the other steps in this job, this step always runs even if the preceding step fails. Test reports are displayed on the Tests tab for a selected build life. Reports are also written to the location you specified with the Source Directory field. Test files that match the pattern that is specified in the Include Patterns field are written to the same directory.
- Click Save.
Creating the upload artifacts step
Upload the build artifacts to the CodeStation repository.
Procedure
- Click the Insert After action for the Publish Unit Tests step.
- On the Steps dialog, click Build Systems, and then click CodeStation.
- Click Upload Artifatcs, and then click Select.
- In the CodeStation-Upload Artifacts window, in the Name field, type Upload Artifacts.
- Click Save.
Creating the assign success step
If all previous steps are successful, this step assigns a status of Success to the entire job. If the preceding steps are not successful, this step does not run and the next step runs instead.
Procedure
- Click the Insert After action for the Upload Artifacts step.
- On the Steps dialog, click Build, and then click Assign Status.
- In the Name field, type Assign Success.
- In the Status list, select Success.
- Click Save. Because the Pre-Condition Script field is set to All Prior Success by default, you can accept the value.
Creating the assign failure step
This step assigns a status of Failure to the job. The step runs if any of the preceding steps fail.
Procedure
- Click the Insert After action for the Assign Success step.
- On the Steps dialog, click Build, and then click Assign Status.
- In the Name field, type Assign Failure.
- In the Status list, select Failure.
- Display the Pre-Condition Script list, and select Any Prior Failure.
- Click Save.

Lesson 3: Creating a project template
About this task
Because project templates are reusable, you can apply the same standards to similar projects. Properties can be defined and the values supplied later by the projects created from the templates. A project template might always use a particular type of build script, for example, but the name or location of the script can vary by project.
In this lesson, you create a project template that you use later to create the tutorial project.
Procedure
- On the IBM® UrbanCode™ Build dashboard, click Templates. The Projects tab is open by default .
- Click Create.
- In the Name field, type Demo Project Template.
- Click Save. The Main tab for the new project template is displayed.
- Click Build Pre-Processing, and click Edit..
- Click Agent Pool Selection, and then select the agent pool you created when you configured the tutorial system.
- Click Save.
Lesson 4: Creating a source template
A source template is a reusable source configuration that can be used by any project that requires the same source type.
Before you begin
Ensure that you installed the Git source-type plug-in before you start this lesson.
About this task
In this lesson, you define a Git configuration that is used by the tutorial project.
Procedure
- On the IBM® UrbanCode™ Build dashboard, click Templates, click Source, and then click Create.
- In the Source Type list, select Git. All installed source-type plug-ins are listed.
- Click Select. Fields that are related to the selected source type are displayed.
- In the Name field, type GitHub.
- In the Working Directory Script list, select Default Workflow Directory.
- In the Remote URL field, type ${p:git.project}. This refers to a property you create in the next section. You supply the property value when you configure the project.
- In the Branch field, type ${p?:git.branch}.
- Click Save.
Creating properties for the source template
Define the properties you referenced in the previous section.
Procedure
- If the Source tab is not already displayed, then on the IBM UrbanCode Build dashboard, click Templates, click Source, and then click the GitHub source template that you created earlier in the lesson.
- Click Properties, and then click Create.
- Create the git.project property by completing these steps.
- In the Name field, type git.project.
- In the Label field, type Git Project. The label text identifies the property to users that use the source template.
- In the Description field, type Path of the GitHub project within the account. The description text is displayed to users.
- In the Display Type list, select Text.
- In the Value area, accept the default option Defined. The Value option determines when and where the value for the property is defined. By selecting Defined, you can provide a value in the Default Value field, or supply the value on the project configuration before the project runs.
- Leave the Default Value field blank. You define the property value when you configure the project.
- Select the Value Required check box.
- Click Save.
- Create the git.branch property by completing these steps.
- On the Properties tab, click Create.
- In the Name field, type git.branch.
- In the Label field, type Git Branch.
- In the Description field, type Source branch. Leave the field blank for the master branch.
- In the Display Type list, select Text.
- Leave the Default Value field blank.
- Clear the Required check box.
- Click Save.

Lesson 5: Creating a process template
Build a process template for the tutorial project.
About this task
In this lesson, you create a process template, define a process, create a property, and an artifact set that is used by the project.
Procedure
- On the IBM® UrbanCode™ Build dashboard, click Templates, click Process, and then click Create.
- In the Name field, type Demo Build Process.
- Under Type, make sure that Build Process is selected.
- Click Save.
Results
The Main tab for the new process template is displayed.
Creating a process definition
Process definitions identify the jobs that comprise a build.
About this task
In order for a job to be used in a project, it must be assigned to the process. A process can have several jobs and their order in the process is determined similarly to the way steps are inserted into jobs. In this lesson, you assign the job you created in the last lesson to a process definition.
Procedure
- On the IBM UrbanCode Build dashboard, click Templates > Process.
- In the Process Templates page, click Demo Build Process, and then click Definition.
- Click Start, and then select Insert Job After. The Insert Job After action is displayed after you click Start, as show in the following figure:
- In the Insert Start Job window, in the Job list, select the job you created in the last lesson, Demo Job.
- In the Pre-condition list, select Always.
- In the Agent Selection area, select Agent Pool Selection, and then select the agent pool you created when you configured your tutorial system. An agent in the agent pool runs the jobs assigned to the workflow.
- In the Working Directory list, select Default Workflow Directory. An agent's default working directory is:
agent_directory/var/work/project/
- Click Insert Job.

Creating process template properties
Define the property you referenced in Lesson 2.
About this task
In this step, you define the property you referenced in the Maven Build step, ${p:maven.goals}
Procedure
- Using the Demo Build Process, click Properties, and then click Create.
- In the Name field, type maven.goals.
- In the Label field, type Maven Goals.
- In the Display Type list, select Text.
- In the Default Value field, type package. This is a Maven lifecycle build phase.
- Select the Value Required check box.
- Click Save.
Creating process artifact sets
Generated artifacts are assigned to an artifact set. An artifact set is a collection of build artifacts.
Before you begin
Ensure that you configured a Maven artifact set before you start this step.
About this task
In this lesson, you configure the artifact set that is used by the project.
Procedure
- Ensure that the window for your build process is displayed and click Artifacts, and then click New Artifact Config.
- In the Artifact Set list, select the artifact set you created earlier, maven.
- In the Base Directory field, type target.
- In the Include Artifacts field, type *.jar.
- Click Save.
Lesson 6: Creating a project
You use projects to configure and run builds. After a build runs, projects provide a wealth of information that you can use to manage the project lifecycle and troubleshoot problems.
Before you begin
Ensure that you completed all of the preceding steps before you start this lesson.
About this task
Projects are built from templates. In this lesson, you will use the templates that you made earlier to create the tutorial project. You can run builds automatically on a predetermined schedule, or you can run builds manually, as you do in the tutorial. To define the tutorial project, you select the process that you defined earlier. When you start the build, the workflow begins running the job that you created with the job template. The project determines the source code to use, and manages any dependencies. Each build generates a unique build life ID.
Procedure
- On the IBM® UrbanCode™ Build dashboard, click Projects, and then click Create.
- Select the project template that you created in Lesson 3, Demo Project Template.
- In the Name field, type Demo Project.
- Click Save.
Configuring the project build process
A project must be associated with a build process. A project might have any number of build processes associated with it.
Procedure
- Ensure that the Configuration tab for the Demo Project project is displayed, then, under Build Processes, click New.
- In the Template list, select Demo Build Process, and then click Select. The Maven Goals field is derived from the process template that you created in last lesson.
- In the Name field, type Demo Build.
- In the Maven Goals field, accept the value, package. The package value is a basic Maven lifecycle build phase. The packageattribute instructs Maven to put the compiled code into a distributable format, such as a JAR file. You can use the tutorial project to run other Maven builds and change the goals.
- Click Save.
Results
The Configuration tab for the new build process is displayed.
Configuring the project source
A project's build source is defined by assigning a source template to a build configuration.
Before you begin
Ensure that the Configuration tab for the build process you defined in the previous section is displayed.
About this task
You define the source configuration by selecting the source template that you created earlier, and by using template properties to identify the source location.
Procedure
- Under Source Configuration, click Create.
- In the Source Template list, select the source template that you created earlier, GitHub, and then click Select.
- In the Name field, type GitHub.
- In the Repository list, select the repository that you created earlier, demoHub.
- In the Git Project Path field, type junit. Because the project uses the master branch, you can leave the Git Branch field blank.
- Click Save.

Lesson 7: Running the build
Run the project build process to transform the source code into the finished application, JUnit.
Before you begin
Ensure that you completed all previous steps in the tutorial.
About this task
You run a build by running a build process that is defined for the project. The build process takes the source material and transforms it, using a job that is assigned to the project, into the final output.
Procedure
- On the IBM® UrbanCode™ Build dashboard, click Projects, and then expand the project that you created in the last lesson, Demo Project. Builds configured for the selected project are listed beneath the project, as shown in the following figure:
- Click DemoBuild. The Main tab for the DemoBuild project build is displayed.
- Click Build. The build process starts and the My Activity tab for the build is displayed. The build, with a new build life number, is listed with a status of Running, as shown in the following figure:
Refresh the My Activity page. If the build is successful, the status changes to Complete; otherwise, the status changes to Failed. A successful run is shown in the following figure: