Now that we have set up all the necessary permissions between GitHub, Jenkins and the slave node, we are ready to configure some tests for the simple factorial code that is in your fork of the PrincetonUniversity/jenkinstutorial repository.

When you save your configure, you will see a note pop-up like this one:

This is because the Jenkins configuration is saved in a Git repository itself. This way if you ever make a mistake in your configuration, and you cannot remember what you changed, you can ask the Jenkins administrator to revert to a previous configuration. In the pop-up menu, you can either enter a comment for this commit or leave it blank. Then click on Submit comment.

Creating a Simple Build with Manual Trigger

Project Identity And Build Rotation

First, to save disk space on the Jenkins server, we will only keep the build logs for 5 days with a maximum of 10 builds. You can change this to something that makes more sense to you.

Slave Node

Check the box Restrict where this project can be run. In the Label Expression box enter the name of the slave that the Jenkins administrator gave you. In our case, tiger1_luet because the slave node name is tiger1 and my Princeton netid is luet.

Source Code Management (Git)

The build should run for a while and when it stops, it should have a blue ball on the left of the number. You can also ssh onto the slave node directly and you should see that the jenkinstutorial repository was cloned in the directory jenkins in your home directory.

Add a test

We will now add a test. We don't specfify any Build Triggers for now, we will be testing by triggering a build manually with the BuildNow button.

Add e-mail notifications

Now we will have Jenkins send you an e-mail each time a build is run.

Automatically Trigger A Build When Someone Opens a Pull-Request

Using the Build Now button is useful for testing, but in production mode you want the tests to be run automatically.

We will now add a build trigger that will start a build automatically when someone opens a Pull-request toward your clone on GitHub. A great advantage of testing on a pull-request is that the changes are tested before they are committed to the git repository.

Changes on the Jenkins Server

In the Configure menu:

Changes on GitHub

You need to add a Webhook to your GitHub account. A Webhook is a mechanism for GitHub to send a message to the Jenkins server when a Pull-Request has been opened.

Open a Pull-Request To Test the New Settings

Now we will make a change to the code and open a Pull-request to merge the changes. We will do it directly on the GitHub web site but you could do everything on the command line if you are familiar with git. We will simply add a README file to the repository.