Note the version number! If you directly install the default jdk, it won’t be 8!
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Check if it’s running by:
sudo systemctl status docker
Now we can finally install Jenkins.
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins
Next steps we will start Jenkins and set it up.
Then we have to configure docker so that it is managed by non-root user, and we don’t have to type
To do this, we create a new group and add the jenkins user.
sudo usermod -aG docker jenkins
sudo systemctl start jenkins
If everything is fine, you will see something like:
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Tue 2018-11-27 22:28:53 UTC; 2min 23s ago
Tasks: 0 (limit: 1152)
Nov 27 22:28:51 systemd: Starting LSB: Start Jenkins at boot time...
Nov 27 22:28:51 jenkins: Correct java version found
Nov 27 22:28:52 jenkins: * Starting Jenkins Automation Server jenkins
Nov 27 22:28:52 su: Successful su for jenkins by root
Nov 27 22:28:52 su: + ??? root:jenkins
Nov 27 22:28:52 su: pam_unix(su:session): session opened for user jenkins
Nov 27 22:28:52 su: pam_unix(su:session): session closed for user jenkins
Nov 27 22:28:53 jenkins: ...done.
Nov 27 22:28:53 systemd: Started LSB: Start Jenkins at boot time.
If you are seeing errors related to wrong Java version, check the first step of this article.
Now you can go to
http://domain or ip:8080 to see your Jenkins app.
You will need to copy and paste the password to prove that you are the owner of this server.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Now you will be able to log in and create admin users and stuff.
Next I will build a Django + docker project as an example.
Now assume I have a project on github. I want to create a pipeline to checkout the source code and do something with it.
First create a new job. In the select panel, select
For now, we will head directly to the Pipeline section. In the script part, enter following:
sh 'echo "Hello World"'
git branch: 'master',
Since this is our first test, we will just do something really simple.
We are going to test if the pipeline script works, so I’m just gonna put in
echo "Hello World" in shell script. If everything works well, we will see this in console logs.
Next is checking out source code.
In this case, I am using github, so I have to input my credentials for github in
jenkins > Credentials > Global > Add Credentials.
Choose the one with username and password, input your github credentials, and give it ID
Remember, if you are using the username and password authentication, you have to use the HTTPS url for
github instead of the SSH one. The
credentialsId in script is the ID that we have for credentials.
Now save and go back to the item page, and click “Build Now”. If the grid box turns green, it mean your pipeline has successfully built and run.
Congratulations! You’ve built your first Jenkins pipeline! Now move on to the 2nd part of this tutorial.