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.
Creating a job
Most job steps are created from plug-ins. Plug-in steps can be thought of as distinct pieces of automation.
Create a job by completing the following steps:
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.

After a job has a step, the Create Step button is no longer used and actions are used instead to insert steps.
Cleaning the workspace
To ensure that no files from a previous build get incorporated into the new one, add a step to clean the agent's workspace. This step is part of most build jobs.

Populating the workspace
This step places the checked-out code (defined later in the project's source configuration) in the agent's workspace.
- 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.

Creating the set version step
Create a version ID that Maven can use.

Creating the Maven build step
This step uses Maven to build the project.

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.

Creating the upload artifacts step
Upload the build artifacts to the CodeStation repository.
- 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.

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.
- 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 checkpoint
In this lesson, you created job and added the steps required to build JUnit.
This job builds JUnit and assigns a status to the job. It also runs the JUnit plug-in step to create a report about the job. A job can use steps from any installed plug-in. Steps have preconditions that determine whether they run. Steps are configured individually as you insert them into a job.


