Configure a local Jenkins instance

This simple how-to guide will show you how to setup your own Jenkins instance. Jenkins is a tool that can be used to execute your CI/CD jobs. It can later be integrated with many other plugins.

This guides scope will be just to get a simple “hello-world” project up and running. I use Jenkins to do the compilations and local deploys of my applications. You can use it as well for this and any job you would like to setup. Enough of this! Let’s get to work!

Docker Compose

We will use a docker-compose file to manage our Jenkins instance, this will allow me to have it restarting automatically whenever I restart my computer since I don’t want to keep starting it manually. We will start with a simple version like this(docker-compose.yml):

version: “3.9”
services:
jenkins:
build:
context: .
dockerfile: Dockerfile
container_name: jenkins
restart: always
ports:
- "8080:8080"

As you can see from the above code we are mentioning a Dockerfile under the “dockerfile” keyword. Let’s create this file (Dockerfile):

FROM jenkins/jenkins:lts-jdk11

With these simple steps we should be able to get to our “project” root directory and execute the following command:

docker-compose up

This will get you a simple instance of Jenkins running. If we pay attention to the logs we can find a password generated by Jenkins we can use it to login or simply check it whenever we want in the path provided in the logs.

Now we should be able to navigate to “http://localhost:8080. Notice that we are able to access this page because we opened this port in our docker-compose file, under the “ports” keyword. Now that we have access to Jenkins, we can start the configurations. The first step is the secret that can be retrieved from the logs or from the shown path.

Getting started page from Jenkins

On the next page, we will choose with which type of configuration we will want to move forward, here you can choose the “Install suggested plugins” to play around with Jenkins, but later, you should explore and choose the plugins that you require for your use-case.

Plugins Installation

On the next page, you will see the different plugins being downloaded and installed.

Downloading and installing the different plugins

After all these configurations are made you are able to get to the Jenkins main page. This is how it should look:

Jenkins dashboard

Having reached this step, now it is time to create our first Jenkins Job! In order to accomplish this, you should click “create job”.

Create job option

Now we will start specifying what type of job we are going to create. Since this is a very simple job we can choose the “Freestyle project” and move forward.

Naming and choosing the type of job

Entering the configuration of this job/pipeline we can see a bunch of configurations. One more time, we are pursuing the defaults but later you will want to explore these options in detail.

Job configurations

Now we need to take care of that nice step of actually printing our “hello world” somewhere right? Here we go!

Execute shell option
Writing the “hello world” message

Move to the bottom of the page and click “Save and apply”. And that’s it, our first Jenkins job is configured. Now, how about we try to run it?

Triggering a build
Job execution history

Finally to see your “Hello world” printed, simply click on your first successful execution and choose the “Console Output” option.

Console Output

Conclusion

Jenkins is a very useful tool when it comes to configuring CI/CD strategies it gives you the possibility of customizing almost everything in your pipelines. This is possible because of the plugins available in the market. If you would like to see some topic related to this let me know in the comments below.

Thanks for your time reading this story, hope it helped you!

--

--

--

Software Engineer | Learning new things

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

FLASHBACK TO OCTOBER 2017

There are only 6 types of developer. Which are you?

How to use Heroku to deploy your PHP website.

How to Write a Concurrent FTP Server in Go (Part 2)

ARTH Task-16

Documentation, Interviews, and Meetups

Once you plant a seed, leave it to grow

White Box Testing: When and How to Apply It

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Xavier Alves

Xavier Alves

Software Engineer | Learning new things

More from Medium

How to Setup CI/CD Pipeline with Jenkins and Unity Test Runner? (Complete Tutorial)

How To Install Jenkins on Ubuntu 20.04

Setup GitLab runner on AWS-ec2

Build Your CI & CD Pipeline with Jenkins