Skip to main content

Upstream and Downstream Projects

Updated May 15, 2020 ·

Lab Environment

In this lab, we have the following Linux machines, and we will use a local computer (laptop) to connect to them.

  • jenkinsmaster

You can choose to set up a virtual machine on your computer or create instances in the cloud. In this case, EC2 instances are used.

Note that for this lab, we'll only be using jenkinsmaster and you can disregard the other tstsvrs and jenkinsslave1 for now.

Setting Up Jenkins

If you have your Jenkins server already setup, you can skip this section. There's an option to manually install Jenkins on a Linux machine or you can also use Ansible playbooks to perform the entire installation of Jenkins on this machine.

To setup Jenkins:

Create the Folder for the Builds

Create a simple test job that will echo out a text. Also create a folder named Test-builds. To create the folder

New Item > enter a folder name > Folder > Ok

Back on the dashboard, you should now see the new folder created.

Create the Upstream Project

Create a simple upstream job that will trigger the second job when it the upstream job is done.

New Item --> Enter an item name --> Freestyle project --> Ok 

In the Build section, click:

Add Builds Step --> Execute shell

In the Command field, enter:

echo 'I am the upstream project'

Then hit Save.

Click Build Now to make sure it works. Open the most recent build under Build History in the left panel then open Console Output.

Create the Downstream Project

Create the downstream job the same way you created the upstream job.

New Item --> Enter an item name --> Freestyle project --> Ok 

In the Build Triggers section, click:

Build after other projects are built --> Projects to watch: --> job-upstream

In the Build section, click:

Add Builds Step --> Execute shell

In the Command field, enter:

echo 'I am the downstream project, triggered by the first one'

Then hit Save.

Going back to the folder Test-builds page, we now have two

Click the job-stream and then Build Now. Then click the latest build under the Build History in the left panel and click the Console Output.

You should see this line:

Triggering a new build of Test-builds » job-downstream 

Exit out to the folder and here we'll see that the job-downstream now has a green checkmark beside it. This means it was triggered and the build was successful.

Click job-downstream then select the latest build under the Build History in the left panel. Click the Console Output.