Linking Jobs in Jenkins

1 hour
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab I am going to issue you a challenge: use Jenkins and its plugins to build an artifact. You will be using no less than three projects that need to be linked in order to produce the artifact. Are you up to the challenge?

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create project1

This project requires the Parameterized trigger plugin. Go to Manage Jenkins, then Manage Plugins, and install the parameterized trigger plugin.

Configure project1 to take a string parameter. Call it what you like. Set the default to what you like.

Create a build step for execute shell. Put in the following as the build step ($var is the name of the parameter you gave to the previous step):

echo "name="$var > project1.txt

Post build, archive the artifact project1.txt and fingerprint it.

Post build, this project should trigger project2 and send parameters from the project1.txt file.

Create project2

This should be a parameterized project.
It should have one string parameter called name.
The build step should be:

echo "Hello" $name > project2.txt

The artifact project2.txt should be archived and fingerprinted.
Post build, this should trigger a build on project3.

Create project3

This project requires the copy artifact plugin.

Go to Manage Jenkins and install the copy artifact plugin.

Create the project as a Freestyle job, in the build steps.

First, copy the project2.txt artifact from project2.
Second, create the project3 artifact by creating a shell build step:

content=`cat project2.txt`
echo $content "this is from project3." > project3.txt

Archive the file project3.txt and fingerprint the archive.
Verify that the file contains the required text.

Additional Resources

In this challenge you will be required to create three projects.
Each of these projects should be Freestyle projects.

All artifacts should be archived and fingerprinted.

The artifacts should be named for their project:
project1.txt, project2.txt, and project3.txt.

The method of passing data from project1 to project2 cannot be the same as the method of passing it from project2 to project3.

project1 should take one parameter, which is a person's name, and should create one artifact.
This artifact should be the parameter for project2 in the form: variable=value.
It should send the parameter to project2 from its artifact and trigger project2.

project2 should receive a parameter from project1, and then respond to that parameter with Hello <parameter>.
This project should produce one artifact, and it should trigger project3.

project3 should copy the artifact from project2.
It should use the contents of the artifact to produce the final artifact.
This artifact should contain the phrase:

Hello <name from project 1> this is from project3.

Remember that this challenge may require additional plugins to complete. Please feel free to install plugins as necessary.

Logging In

In a web browser, navigate to the public IP address of the Jenkins master (on port 8080). The login credentials are:

  • Username: student
  • Password: OmgPassword!

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?