How To Install Jenkins on Ubuntu 18.04

Jenkins – automation software

Jenkins is an automation server, that automates repeating tasks that is used in continuous integration and development.

It can also be used as an advanced crontab that send you an e-mail whenever a jobs has failed with a log from the console output.

It can pull code from a repository and trigger every thime there is a new release or it can be triggered by a push from github or other kinds of systems that can use webhooks

Its very userfriendly to setup and use.

This guide describe how to install it on a brand new Ubuntu 18.04 instance.

INSTALL JAVA

sudo apt install default-jre

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

sudo systemctl enable jenkins

sudo systemctl start jenkins

SETTING UP JENKINS

Start your browser and go to the url where jenkins is running

http://your_server_ip_or_domain:8080

You should see a Jenkins screen that asks for a generated install password

Go to you terminal and type this to get the password

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

ALLOWING JENKINS TO EXECUTE AS SUDO

If you have the needs to give Jenkins access to execute commands as root trough sudo then the solution to is to add this line in the /etc/sudoers file

jenkins   ALL=(ALL:ALL) NOPASSWD:ALL