install jenkins

How To Install Jenkins on Ubuntu 16.04

Installing Jenkins

add the repository key to the system

$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -

Debian package repository address to the server’s sources.list:

$ echo deb https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
update so that apt-get will use the new repository

$ sudo apt-get update

install Jenkins and its dependencies

$ sudo apt-get install jenkins

start Jenkins

$ sudo systemctl status jenkins

Opening the firewall

Jenkins runs on port 8080, so we’ll open that port using ufw:

$ sudo ufw allow 8080

We can see the new rules by checking UFW’s status.

$ sudo ufw status

http://ip_address_or_domain_name:8080

In the terminal window, we’ll use the cat command to display the password

$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

click the “Install suggested plugins” option, which will immediately begin the installation process

When installation is complete, then set up the first administrative user.

Click “Start using Jenkins” to visit the main Jenkins dashboard :



way to change home directory of Jenkins Server

we will create a new folder in our home directory.

$ sudo mkdir ~/Jenkins

Now copy all the content from original Jenkins home to this directory

$ cp -rvf /var/lib/jenkins/* ~/jenkins

Once the copy operation has been completed, we will update the environment variable for Jenkins home directory

$ export JENKINS_HOME=~/jenkins

home directory for the Jenkins has been changed but the updated values for env varaible will only hold for current session. To permanently update the variable, we need to make changed in ‘.bash_profile’ file located in our home directory

$ sudo nano ~/.bash_profile

export JENKINS_HOME=~/jenkins

Now restart the jenkins service to implement the changes

Now create any program in your local system and then open jenkins create new item then add execute shell in build option

Add commands for the program in this shell

Connection with git

Click on the Manage Jenkins button on your Jenkins dashboard:

Click on Manage Plugins

In the Plugins Page, Select the GIT Plugin Install it without restart.

Integrating Jenkins with GitHub

Enter the item name, select job type and click OK. We shall create a Freestyle project

Once you click OK, the page will be redirected to its project form. Here you will need to enter the project information:

Enter the Git repository URL to pull the code from GitHub.

As you can see in the above picture first we need to create a connection git and jenkins