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!
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):
As you can see from the above code we are mentioning a Dockerfile under the “dockerfile” keyword. Let’s create this file (Dockerfile):
With these simple steps we should be able to get to our “project” root directory and execute the following command:
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.
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.
On the next page, you will see the different plugins being downloaded and installed.
After all these configurations are made you are able to get to the Jenkins main page. This is how it should look:
Having reached this step, now it is time to create our first Jenkins Job! In order to accomplish this, you should click “create job”.
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.
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.
Now we need to take care of that nice step of actually printing our “hello world” somewhere right? Here we go!
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?
Finally to see your “Hello world” printed, simply click on your first successful execution and choose the “Console Output” option.
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!