[Jenkins] Quick Way to Setup Jenkins

If you ever heard about CI/CD before, you must heard about Jenkins. Jenkins is the leading open source automation server which can build your code to complete your Continuous Integration and Continuous Delivery. I have been using Jenkins for a while. I will do a quick walk-through to guide you how to setup your first Jenkins server quickly and how to add worker agent.

In this article, I will use docker to install Jenkins as example. There are lots of different way to do it. Please refer here. Let’s start it

0x01 Installation

First, you have to create one folder to store your persistent data, like users profile and job files.

$mkdir -p $HOME/jenkins/data/

And then run the following command to kick off your Jenkins server via docker.

$docker run --name jenkins -d --restart always \
-p 8080:8080 -p 50000:50000 \
-v $HOME/jenkins/data:/var/jenkins_home

And then open up your browser and connect to You will see the following.

Type the following command to get your initial password:

$cat $HOME/jenkins/data/secrets/initialAdminPassword

The system will walk you through the things you need to do. Like install suggested plugins and create first Admin user. Please see below:

After all the prerequisite done, you will see the following and that means you’re done. Congratulation !!!

0x02 Setup Your Agent

I will setup my Jenkins worker agent using Ubuntu 20.04 for my example. First, you have to have one Ubuntu 20.04 ready to go and ssh server enabled as well. Creating one user for Jenkins controller connection:

$useradd jenkins -s /bin/bash -d /home/jenkins -g docker
$passed jenkins

And then using the following command to install openjdk on Ubuntu 20.04.

$apt install software-properties-common apt-transport-https -y
$add-apt-repository ppa:openjdk-r/ppa -y
$apt install openjdk-8-jdk -y

0x03 Connect Controller to Agent

At this moment, your Jenkins agent now is ready to go. First, you have to create one credential for agent login. Go to Dashboard -> Manage Jenkins -> Manage Credentials -> Jenkins -> Global Credentials -> Add Credentials. Choose Username with password in the Kind field, and input username/password pair of your agent Ubuntu 20.04. See below:

After above, go to Dashboard -> Manage Jenkins -> Manage Nodes and Clouds and click New Node. Input the needed information for your agent Ubuntu 20.04. See below:

After clicking Save, wait for a while. You will see your newly added agent now is up and running.

0x04 Setup Freestyle Project

So it’s about time to test if your job can run on newly created node successfully. Go to Dashboard -> New Item, and enter the item name and choose Freestyle project. In this project, I will just echo node name and job url and no more. Please check below:

After this, click Save and Build now, and click the the latest job number #9 in my example and click Console Output. You will see the node name is TestNode and job url is

So at this moment, you Jenkins controller and agent now are up and running successfully. You can do your job automatically. You can pull your code from Github and build/test it automatically as well. I will teach you how to setup your pipeline job on Jenkins in the next article. Please stay tuned. :)