Jenkins: Getting Started (PART 1)
Automation Servers may be seen as complex and too hard to get started. But the basic automation will not take much time to be done.

There are a few key topics that will jumpstart your project automation. This article will cover the first one: installing Jenkins into any platform.

Jenkins History

In mid-2006 or 2007, Kohsuke Kawaguchi founded the project called Hudson. At that time he was working to Sun Microsystems. In a very brief manner, after Sun has been bought by Oracle a little turbulence happened in the community. The end of this history was a fork of the project to GitHub. Previously it was hosted at java.net. This process motivated a project naming change from Hudson to Jenkins, due to Hudson’s naming rights. So if you are searching for Jenkins don’t get surprised if you meet Hudson information.

Nowadays, Hudson project still exists but in a corporate way and not so active. On the other hand, Jenkins is on fire with a high community acceptance and many great features always coming.

One of the key committers of the project is CloudBees. They provide an enterprise version of Jenkins with commercial support. And as Chief Technology Officer (CTO) they have Kohsuke, wise choice.

Prerequisites

As a Java tool, Jenkins only needs Java 8 version pre-installed. Can be the JRE or the JDK. Oracle has a complete guide to install Java in any kind of Operating System, take a look.

Installing

At the time of this writing, the Long-term Support (LTS) is at 2.73.3 version. It is delivered every 12 weeks. But they also have a weekly version delivery with bug fixes and latest features which is at 2.91 version.

The download page has multiple types of installations. Let’s pick up the simplest one, the Generic Java Package.

Download the package that has about 70 MB. Open the terminal, access the download file location and execute:

java -jar jenkins.war

That’s it! Access localhost at port 8080 and smile 🙂

You can also add some parameters, like a different initialization port avoiding conflicts:

java -jar jenkins.war --httpPort=8090

Every time you need Jenkins up and running you will need to execute this command. It blocks your current terminal window writing Jenkins’ output log. Press [CTRL + C] to stop it.

Getting Started

You are now on the Unlock Jenkins page. Check your terminal searching for the admin generated password. Here is an output log from a Mac OSX installation.

...
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

0c699a93011248a980d172eea28de063

This may also be found at: /Users/<your_user_home>/.jenkins/secrets/initialAdminPassword

*************************************************************
...

Copy and paste it to proceed installation. Jenkins will suggest the most used plugins that for now is enough. This step can take a while according to your internet connection.

Then, create your own admin user. It is a good practice considering that Jenkins track your actions. You can also receive custom notification straight to your mail inbox.

It’s ready to use! Welcome to the automation paradise.

Location

This article will not get into details but it is important to know the basics about it.

Consider the Jenkins home directory as a database. It’s very important to take care of it. This folder handles from simple configurations up to your entire automation jobs.

Be aware that it is important to back up these files for your security. In contrast, if you are learning how to use or want to restart your entire Jenkins’ configuration you only need to delete this folder to get rid of everything.

As you may have noticed, on the Generic Java Package installation, the .jenkins folder will be created at the user’s home directory.

/Users/<your_user_home>/.jenkins/...

Docker Installation

This is the only installation that doesn’t require Java pre-installed, only Docker. Run the following command:

docker run \
-p 8080:8080 \
-p 50000:50000 \
-v $(pwd)/jenkins_home:/var/jenkins_home \
jenkins/jenkins:2.73.3
  • -p 8080… : The default Jenkins listening port.
  • -p 50000… : JNLP port used to connect a slave agent.
  • -v… : Explicit volume to store the Jenkins home directory. It will maintain the data even after the container has been stopped or deleted. Note that a folder named `jenkins_home` will be created at your local folder from where this command is running.
    • $(pwd): Local folder for Unix environments.
    • ${PDW}: The same using Windows PowerShell.
  • jenkins/… : Tag location at DockerHub to the 2.73.3 version. At this moment the lts tag would have the same result.
jenkins/jenkins        2.73.3              5f9cc03c136c        2 weeks ago         812MB
jenkins/jenkins        lts                 5f9cc03c136c        2 weeks ago         812MB

Other Installations

In a very simple explanation, all other installations execute the same process as the Generic Package but at the end, a service will be created to ensure Jenkins is up and running even if you restart your machine.

It is up to you to choose the option that fits your scenario best.

What Next

It is time to test, play and have fun. Follow these steps to start with your first automation server. The next article will cover the recommended Jenkins plugins understanding their importance.

Let’s automate!


Leave a Reply

Your email address will not be published.