Jenkins

From PKC
Jump to navigation Jump to search

Jenkins, originally called Hudson, is an Open Source CI/CD tool.

To install Jenkins on a Ubuntu 20.04 machine from scratch, one can go to the Github project: CleanSlate

Installation Guide

For installation on Ubuntu 20.04, administrators of the machine can follow the instructions below[1]:

Step 1: Add the repository key

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

Step 2: Append the Debian repository package to source.list.d/jenkins.list

sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

Step 3: Update all software through apt update

sudo apt update

Step 4: Install Jenkins and its dependencies

sudo apt install jenkins

Step 5: Use systemctl to start Jenkins service

sudo systemctl start jenkins

Step 6: You may check if Jenkins's status

sudo systemctl status jenkins

Step 7: Visit Jenkins on its default port:8080, go to a browser and type in the following URL: http://your_server_ip_or_domain:8080

The browser will prompt you to type in an initial password.

Step 8: On your server side, go to the terminal and type in this instruction:

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

Step 9: The next browser page will ask you to install some plug-ins. You may choose either select plug-ins to install or install default ones. It will take a while for plug-ins to install.

Step 10: After certain plug-ins are installed, you will have to create an Admin account.

Step 11: After creating a default admin user, you will be presented with an Instance configuration page. Provide the information identical to Step 7, for example: http://your_server_ip_or_domain:8080,

Step 12: You are ready to use Jenkins.

Other required settings

To trigger build actions that requires "sudo" status, one must make some modification in the /etc/sudoer file[2]. The instruction is as follows:

sudo visudo

Then just add one more entry:

jenkins ALL=(ALL) NOPASSWD: ALL

References

  1. Digital Ocean, How to Install Jenkins on Ubuntu 20.04, https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-20-04
  2. How to solve "sudo: no tty present and no askpass program specified", https://gist.github.com/hayderimran7/9246dd195f785cf4783d