• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
sharadchhetri.com

sharadchhetri.com

Linux,Cloud Computing And DevOps

  • Home
  • Linux
  • CloudComputing
    • Introduction Cloud Computing
    • Amazon AWS
  • Free E-Books
  • About Me

How to install Jenkins on Ubuntu 18.04 LTS server

November 27, 2018 by Sharad Chhetri Leave a Comment

In this post we will install Jenkins on Ubuntu 18.04 LTS server. For installing the Jenkins, we will use ‘Generic Java Package (war)’. Jenkins is very popular automation server widely use for building,deploying and automating the projects.

It is one of the Open Source Software which is mostly prefer for CI/CD. There are lots of Jenkins plugins available which helps to enhance the function and features.

Hardware and Software Requirements For Jenkins

In this section, we will list Hardware and Software requirements both for installing and managing the Jenkins.

Recommended Hardware Configuration

This is recommended hardware requirements to start with small team. As your requirement grows you have to increase the hardware specs.

  • 1GB RAM or more
  • 50GB or more disk space

Software Prerequisites For Installing Jenkins (war)

  1. Jenkins Stable LTS version 2.138.x [Generic Java Package (war)]
  2. Java version 8
    • Only Java 8 is supported (Both 32 and 64 bit)
    • Older than Java 8 is not supported
    • Java 9 is not supported
    • Java 10 and 11 has preview support

Steps To Install Jenkins On Ubuntu 18.04 LTS Server

In this section, we are installing Jenkins on Ubuntu 18.04 LTS server. It will be standalone Jenkins server. We always recommend to use LTS(Long Term Support) version for any Operating System or software because it provides support for longer period of time.

Install Java

In this section, we are installing Java and then we will set Java environment.

  1. Login to server
  2. Create directory:
    sudo mkdir -p /opt/java
  3. Download Java:
    curl -L -b "oraclelicense=a" https://download.oracle.com/otn-pub/java/jdk/8u192-b12/750e1c8617c5452694857ad95c3ee230/jdk-8u192-linux-x64.tar.gz -O
  4. Untar Downloaded Java Package:
    sudo tar -xvzf jdk-8u192-linux-x64.tar.gz -C /opt/java/
  5. Rename Directory:
    sudo mv /opt/java/jdk1.8.0_192/ /opt/java/jdk8

Set Java Environment

Now set the Java environment.

  1. Create New Profile Script: We use vi/vim. Use your favorite file editor.
    sudo vi /etc/profile.d/java.sh

    And write following contents in script and save the file.

    export JAVA_HOME=/opt/java/jdk8
    export PATH=/opt/java/jdk8/bin:$PATH
  2. Change the script permission:
    sudo chmod +x /etc/profile.d/java.sh
  3. Immediate Java Environment Effect: After setting Java Environment, to make it effective either logout and login again.
    Alternatively, you can also run the source command like this.

    sudo source /etc/profile.d/java.sh
  4. Check Java version:
    java -version

    Example from our system.

    root@server01:/home/user1# java -version 
    java version "1.8.0_192" 
    Java(TM) SE Runtime Environment (build 1.8.0_192-b12) 
    Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode) 
    root@server01:/home/user1# 

Create User For Jenkins

We will create user which will be used by Jenkins Application.

  1. Create user called jenkins and change its shell to bash:
    useradd -d /home/jenkins -m jenkins
    sudo usermod -s /bin/bash jenkins

Install Jenkins by using java war file

In this section, we will use Generic Java war file for installing Jenkins. Always use LTS version.

  1. Create directory for keeping Jenkins war file:
    sudo mkdir -p /opt/jenkins
  2. Download Jenkins war file to /opt/jenkins directory:
    wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war -P /opt/jenkins/
  3. Change owner,group and permission of jenkins war file
    sudo chown jenkins:jenkins /opt/jenkins/jenkins.war
    sudo chmod +x /opt/jenkins/jenkins.war
  4. Switch to Jenkins user
     sudo su - jenkins
  5. Execute Jenkins war file:
    This is important step, when we first time execute the jenkins war file and all goes well then at the end of output it will show temporary jenkin’s admin password which also saved in the file.

    Execute the Jenkins war file.

    $java -jar /opt/jenkins/jenkins.war
  6. Get Jenkins admin initial temporary password:
    Wait for execution process to reach at the point when you found this line “INFO: Jenkins is fully up and running”

    You will also find the temporary initial admin password for Jenkins, copy the password. Here is the sample output.

    ************************************************************* 
    ************************************************************* 
    
    Jenkins initial setup is required. An admin user has been created and a password generated. 
    Please use the following password to proceed to installation: 
    
    840b0ca4d88841d299ab48e2d8a48c02 
    
    This may also be found at: /home/jenkins/.jenkins/secrets/initialAdminPassword 
    
    ************************************************************* 
    ************************************************************* 
  7. Further installation from Web Interface
    In web browser’s address field type Jenkins server ip address or FQDN and use port 8080 to open.
    Jenkins by-default run on port number 8080 (For example http://192.168.123.247:8080).

    Note:ip addr list command will show your server ip address.

    Rest of the installation process is very simple and by reading instruction on screen you can easily complete the setup.

  8. Give temporary admin password which you have got from Step 6. ( Do not use our one, the temporary admin password should be generated in your system on doing Step 6)

    Install jenkins

  9. Click on “Install Suggested Plugins”, it will by-default install all plugins suggested by Jenkins. You can also select a few plugins, for this you have to click “Select plugins to install”

    We recommend to go for “Install Suggested Plugins”.

    Install jenkins on Ubuntu

  10. Now it will start installing the plugins as shown in given below screenshot.
    Install jenkins on Ubuntu 18.04 LTS

  11. Give Jenkins Admin user name and set its password as per your wish. We recommend to set password containing Alphanumeric Characters because it is a good security practice.

    Click “Save and Continue” button after setting Jenkin’s admin username and password.

    Install jenkins on Ubuntu 18.04 LTS server

  12. You will see Jenkins URL information on screen. Click “Save and Finish”.
    jenkins
  13. In next screen, you will see “Jenkins is ready!”. Quite obvious click on “Start Using Jenkins”
    installing Jenkins on Ubuntu 18.04 LTS server
  14. Immediate after click, you will be login to Jenkins Admin Console. You will get first screen of Jenkins.
    installing Jenkins on Ubuntu

In next step we will create Jenkins systemd script. Press CTRL+C on terminal where you have executed the Jenkins war file to run the process.

Create systemd script for Jenkins

Logout from jenkins user shell (Press CTRL+D or type command exit)

  1. Create Jenkins system script file
  2. sudo vi /etc/systemd/system/jenkins.service

    Write the below given contents in file jenkins.service

      
    [Unit] 
    Description=Jenkins Daemon 
    [Service] 
    ExecStart=/opt/java/jdk8/bin/java -jar /opt/jenkins/jenkins.war 
    User=jenkins 
    [Install] 
    WantedBy=multi-user.target 
  3. Give Permission
    sudo chmod 755 /etc/systemd/system/jenkins.service
  4. Reload Systemd Daemon:
    sudo systemctl daemon-reload
  5. Manage Jenkins Service: After creating Jenkins systemd script, you can easily manage the Jenkins service.

    # To start jenkins service

    sudo systemctl start jenkins
    

    # To stop jenkins service

    sudo systemctl stop jenkins
    

    # To restart jenkins service

    sudo systemctl restart jenkins
    

    # To check status of jenkins service

    sudo systemctl status jenkins
    

    # To enable jenkins service to run at booting time

    sudo systemctl enable jenkins
    

    # To disable jenkins service to run at booting time

    sudo systemctl disable jenkins
    

I hope now you are able to run your Jenkins server. To update/upgrade Jenkins or its plugins you can do directly from its admin console and for this you receive notification on admin console (by-default).

Do'nt be greedy, share the knowledge!

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)

Related

Filed Under: Devops, Linux, Ubuntu Tagged With: automation, devops, jenkins, linux, ubuntu 18.04

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Twitter
  • GitHub
  • YouTube

Recent Posts

  • Activate.ps1 cannot be loaded because running scripts is disabled on this system
  • How to install Java (OpenJDK) on Ubuntu Linux
  • How to install Groovy on Ubuntu 20.04 LTS
  • How to Disable selinux in Red Hat or CentOS
  • How to remove date from WordPress Post URL

Top Posts & Pages

  • How to delete mail queue in Postfix
  • How to fix read only USB pen drive in Ubuntu
  • How to start / stop / restart / reload iptables on CentOS 7 / RHEL 7
  • 4 different commands to check the load average in linux
  • How to set hostname and FQDN on CentOS 7 and RHEL 7
  • How to find absolute path of command on Linux / Unix : which command
  • How to create Jenkins user by command line and GUI
  • How to print particular line number by using sed command
  • How to setup Jenkins Credentials for Git repo access
  • make command not found in linux CentOS Red Hat ubuntu Debian

DevOps Posts

  • vagrant cloud flow

    Install Vagrant on Ubuntu and create first VM

  • git jenkins credential github

    How to setup Jenkins Credentials for Git repo access

  • terraform

    how to install terraform in Linux : CentOS-Ubuntu

  • docker image

    How to create Ubuntu docker base image

  • Install Ansible on Ubuntu / CentOS / RHEL

Footer

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Sharad Chhetri is an experienced Linux - Cloud Engineer & freelancer. Working on Open Source Technology since RHEL 4.0 (Red Hat Enterprise Linux). He loves sharing the knowledge which earned from real scenarios. Don't be surprised if you find him in technology seminars and meetup groups. You can contact him on email for freelance projects at admin@sharadchhetri.com. Read More…

Tags

Amazon AWS apache automation awk bash script CentOS centos 7 debian devops docker freebsd ftp ghost git grep hostname jenkins kvm linux linux command linux commands MariaDB Server mysql Nagios nginx Octopress owncloud Owncloud 6 php postfix postgres python Red Hat rpm sed selinux ssh swap ubuntu user management vagrant varnish virtualbox vsftp wordpress

Recent Comments

  • Sharad Chhetri on How to fix read only USB pen drive in Ubuntu
  • iain mckeand on How to fix read only USB pen drive in Ubuntu
  • Sharad Chhetri on Secondary Logging : save all users history command output as log
  • Sharad Chhetri on How to fix read only USB pen drive in Ubuntu
  • er on What is /dev/shm and how to mount /dev/shm
  • Bala on Send nagios report as pdf file via email
  • Terry on How to fix read only USB pen drive in Ubuntu
  • Terry on How to fix read only USB pen drive in Ubuntu

Copyright © 2009 - 2022 · All Rights Reserved sharadchhetri.com · · Privacy Policy ·
· sitemap.xml · ·The content is copyrighted to sharadchhetri.com and may not be reproduced on other websites without our permission. ·

Copyright © 2022 · Genesis Sample on Genesis Framework · WordPress · Log in

 

Loading Comments...