How To Install and Use Jenkins in Ubuntu

To Install and Use Jenkins on Ubuntu

Jenkins is an open source automation server and continuous integration tool. It can be used for building and testing software projects. It provides lots of deploying and automating plugins. This articles gives a clear picture about the installation and the usage of Jenkins in Ubuntu.


Installation of Jenkins

The installation of Jenkins requires adding the key. Run the following command for the same.

root@linuxhelp1:~# wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
OK

Once the key is added, it is essential to add the repository too. It can be done with the following command.

root@linuxhelp1:~# sh -c ' echo deb http://pkg.jenkins-ci.org/debian binary/ >  /etc/apt/sources.list.d/jenkins.list' 

After adding the repository, update it by triggering the following command.

root@linuxhelp1:~# apt-get update
Hit:1 http://in.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://security.ubuntu.com/ubuntu xenial-security InRelease                                              
Hit:3 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease                                    
Hit:4 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease                                  
Ign:5 http://pkg.jenkins-ci.org/debian binary/ InRelease                 
Get:6 http://pkg.jenkins-ci.org/debian binary/ Release [2,042 B]
Get:7 http://pkg.jenkins-ci.org/debian binary/ Release.gpg [181 B]
Get:8 http://pkg.jenkins-ci.org/debian binary/ Packages [1,036 B]
Fetched 3,259 B in 1s (1,777 B/s)
Reading package lists... Done
W: http://pkg.jenkins-ci.org/debian/binary/Release.gpg: Signature by key 150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6 uses weak digest algorithm (SHA1)

Now is the time for installing Jenkins. Invoke the following command for the same.

root@linuxhelp1:~# apt-get install jenkins -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  ca-certificates-java daemon default-jre-headless java-common openjdk-8-jre-headless
Suggested packages:
  default-jre openjdk-8-jre-jamvm fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho
  ttf-wqy-microhei | ttf-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  ca-certificates-java daemon default-jre-headless java-common jenkins openjdk-8-jre-headless
0 upgraded, 6 newly installed, 0 to remove and 416 not upgraded.
Need to get 96.1 MB of archives.
After this operation, 170 MB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 java-common all 0.56ubuntu2 [7,742 B]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 default-jre-headless amd64 2:1.8-56ubuntu2 [4,380 B]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 ca-certificates-java all 20160321 [12.9 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openjdk-8-jre-headless amd64 8u111-b14-2ubuntu0.16.04.2 [26.9 MB]
Get:5 http://pkg.jenkins-ci.org/debian binary/ jenkins 2.28 [69.1 MB]                               
Get:5 http://pkg.jenkins-ci.org/debian binary/ jenkins 2.28 [69.1 MB]                                          
Get:5 http://pkg.jenkins-ci.org/debian binary/ jenkins 2.28 [69.1 MB]                                          
Get:5 http://pkg.jenkins-ci.org/debian binary/ jenkins 2.28 [69.1 MB]                                          
Get:5 http://pkg.jenkins-ci.org/debian binary/ jenkins 2.28 [69.1 MB]                                          
Get:5 http://pkg.jenkins-ci.org/debian binary/ jenkins 2.28 [69.1 MB]                                          
Get:5 http://pkg.jenkins-ci.org/debian binary/ jenkins 2.28 [69.1 MB]              
.
.
.
Adding debian:GeoTrust_Primary_Certification_Authority.pem
Adding debian:Swisscom_Root_EV_CA_2.pem
Adding debian:CA_Disig_Root_R1.pem
Adding debian:OISTE_WISeKey_Global_Root_GA_CA.pem
Adding debian:CA_WoSign_ECC_Root.pem
Adding debian:Camerfirma_Chambers_of_Commerce_Root.pem
Adding debian:SwissSign_Platinum_CA_-_G2.pem
Adding debian:Go_Daddy_Class_2_CA.pem
Adding debian:AddTrust_Public_Services_Root.pem
Adding debian:AC_Raí z_Certicá mara_S.A..pem
Adding debian:E-Tugra_Certification_Authority.pem
Adding debian:Verisign_Class_1_Public_Primary_Certification_Authority_-_G2.pem
Adding debian:certSIGN_ROOT_CA.pem
done.
Setting up default-jre-headless (2:1.8-56ubuntu2) ...
Setting up jenkins (2.28) ...
Processing triggers for ca-certificates (20160104ubuntu1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed  done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...

After the installation, restart the Jenkins service by issuing the following command.

root@linuxhelp1:~# service jenkins restart

The Jenkins service is ready to be accessed. You can launch it by calling the ip address of your machine along with port number 8080 on your browser as follows.

If you see the Getting Started page as above, the next step is to get the admin password. Issue the following command for the same.

root@linuxhelp1:~# cat /var/lib/jenkins/secrets/initialAdminPassword
de6e973e5f7d417e99d908154533aaa8

Now copy the given password from the terminal and paste it on the browser and click continue as follows.

Once the password is given you' ll be taken to the installation window as below. Select your desired option to install the plugins. You can either choose to Install suggested plugins or Select required plugins options.

Once the plugins are installed, it is time to create an admin account. To do that, log into Jenkins and click on Continue as admin.

Now click on Start using Jenkins

Now you' ll be taken to the home page of the Jenkins as below.

To install Plugins in Jenkins

For installing plugins navigate to Manage Jenkins > > Manage Plugins > > Available Tab and select the plugins to install.

To create a new user

If you want to create a new user account, navigate to Manage Jenkins > > Manage Users > > Create User . Enter the required details and click Create User.

Tag : Jenkins
FAQ
Q
Why does my test connection connect successfully but my install/upload fail to connect?
A
a)SOAP commands are sent from the WebSphere Deployer Plugin (WDP) on port 8879 (For WAS ND) or port 8880 (For standalone WAS)
b) When the WDP initiates the deployment, the internal WAS environment looks up the common name of the SSL certificate for the deployment manager (or WAS admin console)
c) If the common name (CN) specified in the SSL cert is not found in the DNS, the upload may fail b
) If the CN matches the DNS name of the WebSphere Deployment Manager or Admin Console, the upload will succeed. Sometimes, you will get a Hostname Verification error. If this happens, you need to make sure the CN matches the hostname of the server you are deployment manager (or WAS admin console). If you have this issue, you must regenerate the root certificate and make it match the DNS.
Q
What is Jenkins on Ubuntu?
A
Jenkins is an open source automation server and continuous integration tool. It can be used for building and testing software projects. It provides lots of deploying and automating plugins.
Q
Are cluster deployments allowed?
A
Yes, you can deploy to 1 or more clusters using this plugin. The latest version has a button called "Show Available Targets" to help you identify where the plugin is allowed to deploy to. You can deploy to multiple targets as long as each target is on its own line.
Q
Can I deploy to multiple versions of WebSphere?
A
Yes, but only if you use another Jenkins server to deploy to the different version (see FAQ #10 above). If you want to deploy to the same to different WebSphere versions from the same Jenkins server, you can't due to classloader issues between the WebSphere jar versions.
Q
I get an ObjectName error when deploying to WebSphere in Ubuntu?
A
This error typically occurs because of a classloader issue. The latest versions of this plugin have tried to rectify this issue by implementing "false". If you have issues, you can always attempt to change this to "true" in the plugin's manifest.