Setting Up Jenkins | MacOS — 2021

Jenkins Part I: Installing Jenkins

Charlie Campbell
4 min readAug 21, 2021

This is a short guide/reminder for myself on how to install Jenkins on MacOS. Most of the content from this blog post will be from my notes during learning Jenkins myself.

Prerequisites

Installing Jenkins

  1. Firstly use brew to install the latest TLS version of Jenkins.
$ brew install jenkins-lts

2. Now start the Jenkins service

$ brew services start jenkins-lt

Bonus: Other notable commands!

# Stop Jenkins
$ brew services stop jenkins-tls
# Restart Jenkins
$ brew services restart jenkins-tls
# Upgrade Jenkins
$ brew upgrade jenkins-tls

3. Continue the setup in a web browser by navigating to http://localhost:8080/ and following the Getting Started guide.

In order to unlock Jenkins copy the string from running the command below and enter that in the administrator password box.

$ less /Users/<your_username>/.jenkins/secrets/initialAdminPassword

4. Once you’ve unlocked jenkins you will be prompted on how you would like to install plugins. I would suggest installing the recommended plugins, you should then see the following screen.

5. Once Jenkins has installed the recommended plugins you will be asked to create the first admin user. After filling out the form click ‘Save and Continue’, you will be asked whether you want to change the location Jenkins runs, I skipped this and clicked ‘Save and Finish’.

6. Now you should be able to login to Jenkins using the credientials you setup.

Eventually we will see a list of projects on this page. However as this is a fresh install this page is empty.

First Jenkins Job

Now that we’ve got Jenkins setup and ready to use, lets create our first job.

  1. Click ‘new item’ in the top left. This will bring up a list of the different types of jobs.
  • Freestyle project: Freely control the way Jenkins manages the tasks you want to automate.
  • Pipeline: A series of steps to produce a final outcome.
  • Multi-configuration project: Multiple jobs that do the same task for different parameters. Can help prevent duplication.
  • Folder: Groups things together.
  • GitHub Organization: Specifically suited for working with code repository. Scans github repo’s for specified files.
  • Mutlibranch Pipeline: Configure jobs on a single repo for different branches.

2. Create a freestyle project called ‘Hello-Jenkins’

After clicking ‘OK’ you will be redirected to the job configuration page.

3. Click the ‘build’ tab in the menu bar then click ‘add build step’ and select ‘execute shell’

4. As advertised let’s create the classic hello jenkins. In the promt for execute shell it allows you to input a command. Let’s type:

echo "Hello Jenkins"

5. After clicking ‘Save’ you’ll be redirected to the job homepage. Alternatively if you wanted to keep working on the Jenkins configuration you can click ‘Apply’.

6. In order to run the job click ‘build now’ in the menu on the left.

You can see that I have already built the job by checking the build history. A green tick will represent a completed successful build. A red cross represents a failure. A blue orb represents a running job.

7. We can verify that the job as run as expected by clicking on ‘#1’ in the build history and clicking ‘console output’. This will now show the job output check for the plain text ‘Hello Jenkins’.

Conclude!

Hopefully by the end of reading this you should have a local instance of Jenkins with a Hello-Jenkins project. This is part one in a series I will be working on to further my own DevOps skills as well as sharing my new found knowledge.

Part II: Coming Soon.

--

--