In this chapter, let's integrate GitHub with Jenkins. Then we will understand how to execute tests from Jenkins pointing to GitHub.
Let's look at the current job configurations in Jenkins.
Click on "FirstSeleniumTestJob" which is cloned from "MyFirstJob".
On the "General" tab in the "Source Code Management" section, change the setting from "None" to "Git".
It then asks for a repository url.
On GitHub I already have a sample project added so let's copy this url and provide it here.
We do not need any credentials for this configuration but in other cases it may be required. We should also provide the branch string that we wish to clone. In our case it is "master".
It is important to update the path of pom.xml. In the previous example we were pointing to a local workspace so we provided the local pom.xml path. But now we are pulling code directly from Git into a Jenkins workspace. So Jenkins will create a workspace in this machine with the same project name as this job name ("FirstSeleniumTestJob") and put the code there. So our target pom.xml path is simply "pom.xml" without an absolute path.
So that's it, let's apply and save the changes. Now we can test it by building the job. Ideally it should check out code from GitHub and then trigger it in a test execution.
The build status appears to be nominal and the test executes successfully. This concludes our discussion on integrating GitHub with Jenkins.
The quiz for this chapter can be found in section 3.7