In this article, we will install Jenkins on Ubuntu and examine the following items:
- Developer commit to source code management system.
- Jenkins job will be notified.
- Jenkins send pull request to GitHub.
Configuration of Jenkins on Ubuntu
First, we have to add the key and source list to apt. Apply, below two commands in order.
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
Now we need to update Ubuntu.
We need to install Jenkins now. Be aware it takes some time to install Jenkins.
apt-get install jenkins
The default port number for Jenkins is 8080. The below screenshot is the entry page or Dashboard of Jenkins.
Restart Jenkins with this command: http://localhost:8080/restart
We need git in our system so we will install it with below command.
sudo apt-get install git
Congratulations, Jenkins environment setup has been completed. 🙂
Integrate Jenkins and GitHub
In this tutorial, we will use GitHub as source code repository. We need to install Jenkins GitHub plugin, for more information visit https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin .
Manage Jenkins page, select Manage Plugins on the available tab search box = github
Above figure shows that, GitHub API Plugin have successfully installed to system.
We will configure Jenkins to trigger a build when a file is modified in the GitHub repository.
- Connect to the Jenkins server again. Click the New Item link in the left navigation.
- Name your build job, and choose Freestyle project. Click OK.
- Copy the URL from your GitHub project.
- In order to manage Jenkins, we need to set executable.
- Create a new job and name it.
- Specify your GitHub project at source code management.
- Add credentials Username / Password
- You can change build trigger using below options.
- If your job is triggered you should below result. It will finish with SUCCESS! 🙂