Skip to main content

Deploying Jenkins Continuous Integration (CI) Server on Ubuntu LTS

For the past few weeks I have been helping Internet-in-a-Box(IIAB) team develop their Continuous Integration (CI) infrastructure setup using Vagrant, VirtualBox and Jenkins CI server.

Running Jenkins server from .war file might be convenient. But it is recommended to deploy GNU/Linux Continuous Integration (CI) server using these instructions.

# Add Debian package repository of Jenkins GPG key:
$ wget -q -O - | sudo apt-key add -

# Then add the following entry to your/etc/apt/sources.list:
$  echo deb binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list

# Update your local package index:
$ sudo apt-get update

# Install Jenkis server:
$ sudo apt-get install jenkins

# Start Jenkins service and verify its status:
$ sudo systemctl start jenkins
$ sudo systemctl status jenkins

# Open http://localhost:8080 in your browser and copy paste in the secret password.
# Follow the on screen instructions to create Jenkins server admin account
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

# Open the ports 8080 through your firewall:
$ sudo ufw allow 8080
$ sudo ufw status

Adding a monit service to monitor the Jenkins server is a good idea. Monit ensures that Jenkins server is restarted automatically when it crashes.

# Create a Jenkins monitoring file with following lines with:
$ sudo nano /etc/monit/conf.d/jenkins
check process jenkins with pidfile /var/run/jenkins/
    start program = "/etc/init.d/jenkins start"
    stop program  = "/etc/init.d/jenkins stop"

Also you'll need to configure mail server to send Jenkins build reports.