Jenkins offers a simple way to set up a continuous integration and continuous delivery environment for almost any combination of languages and source code repositories.
Jenkins offers a simple way to set up a continuous integration or continuous delivery environment for almost any combination of languages and source code repositories using pipelines, as well as automating other routine development tasks. While Jenkins doesn’t eliminate the need to create scripts for individual steps, it does give you a faster and more robust way to integrate your entire chain of build, test, and deployment tools than you can easily build yourself.
How to install Jenkins on Ubuntu 18.04
Install Java Version 8 – Jenkins is a Java based application, hence Java is a must.
Install Apache Tomcat Version 9 – Tomcat is required to deploy Jenkins war file.
Download Jenkins war File – This war is required to install Jenkins.
Deploy Jenkins war File – Jenkins war file needs to be deployed using Tomcat to run Jenkins.
Install Suggested Plugins – Install a list of plugins suggested by Jenkins.
Step 1: Install Java Version 8
To install Java version 8 execute the below command:
sudo yum install java-1.8.0-openjdk
Step 2: Install Apache Tomcat 9
We need to deploy the Jenkins war file by using Apache Tomcat. I will use wget command to install specific version of Apache Tomcat i.e. Tomcat 9 in this case.
- First, to install wget execute the below command:
sudo yum install wget
- Now use wget to download the Tar file for Tomcat 9
wget http://apache.osuosl.org/tomcat/tomcat-9/v9.0.17/bin/apache-tomcat-9.0.17.tar.gz
- Next, extract the contents from this downloaded Tomcat 9 tar file. For this I will use tar command:
tar xzf apache-tomcat-9.0.17.tar.gz
- Provide a username and password for Apache Tomcat.
vim /home/adilcan/tomcat9/conf/tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-jmx"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <user username="adilcan" password="adilcan" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/> </tomcat-users>
- Start Apache Tomcat now, but change directory to Tomcat9
cd tomcat9
- To start Tomcat use the below command:
./bin/startup.sh
- Now open your browser and go localhost:8080 to confirm that Tomcat is up and running.
Step 3: Download Jenkins war File
To get the release list of Jenkins war you can use the URL Jenkins releases
Now download Jenkins war file by using wget command:
wget http://updates.jenkins-ci.org/download/war/2.170/jenkins.war
Step 4: Deploy Jenkins war File
- To deploy Jenkins war file that you have downloaded in the previous step, open your browser and access localhost:8080 again. Now click on the Manager App.
- When you click on the Manager app, it will ask for username and password. If you remember I have given one single username and password for all the roles i.e. edureka. Type the below mentioned username and password and click OK.
Username: adilcan
Password: adilcan
- Now you will be directed to Tomcat web application manager page. When you scroll down you will find an option called Deploy. Over here you need to give the context path, i.e. /jenkins and directory URL, i.e. location of the Jenkins war file in your system in my case it is /home/edureka/jenkins.war and finally click on Deploy.
Step 5: Install Suggested Plugins
- This is the location that contains your one time password for Jenkins i.e./home/adilcan/.jenkins/secrets/initialAdminPassword in my case, it will be different for you. Hence, just copy the path from the screen on your end and go back to the terminal.
- Finally, use the following command to get your one time password:
cat <paste the location that you have copied>
- Just copy this password and paste it in the Administrator password text-box in the Unlock Jenkins page. Please refer to the below snapshot.
- Install suggested plugins.
- Once the plugins are installed, you will be directed to a page where you have to Create First Admin User. Please fill your relevant details.
Congratulations! Jenkins is ready now, once you click on start using Jenkins you will be directed to Jenkins dashboard. You can now use Jenkins to continuously trigger build and test for every change made in the source code.