Setting Up a CentOS VM and Jenkins


I needed a VM to follow along with this book, Jenkins the Definitive Guide. Chapter 2 goes into setting up a Jenkins and Git repo. This article covers the things I had to do to get going.

Getting Started

For our AWS instances we use CentOS. Get the DVD ISO from

For VMs we typically use VirtualBox. Get the installer and extension pack* from
   * Install the extension pack after installing VirtualBox

Creating the VM

This will cover setting up a VM for CentOS.

  1. Fire up VirtualBox
  2. Click the New button
  3. Name your VM
  4. For Type select Linux
  5. For Version select Other Linux (64-bit)
  6. Click Continue
  7. Move the slider to 2GB (2048 MB)
  8. Click Continue
  9. Click Create
  10. Click Continue
  11. Click Continue
  12. Change the disk size to 20 GB
  13. Click Create
  14. Select your new VM from the list
  15. Select Settings
  16. Select Storage
  17. Select the Optical Drive
  18. Select the Disc Icon
  19. Select Choose a virtual CD/DVD disk file…
  20. Find your file and select Open
  21. Select OK

Installing CentOS

This will cover installing CentOS [7] on the VM created in the previous section.

  1. With your VM selected, select Start
  2. Select Install CentOS 7 and press [ Enter/ Return ]
  3. Select Continue
  5. Select Done
  7.  Select Basic Web Server
  8.  In the right pane, select Java Platform and PHP Support
  9. Select Done
  10. Select Begin Installation
  11. During the install, select ROOT PASSWORD
  12. Enter your password (twice)
  13. Select Done
  14. Select Finish Configuration
  15. Select Reboot
  16. After the reboot you will be asked to login, enter root as the login and press [ Enter/Return ]
  17. Next you will be prompted for the password, from Installing CentOS Steps 11 and 12 (above)
  18. If the preceding steps are completed correctly you should end up at the console prompt

Setting Up Jenkins

  1. Ensure java is installed by running {{ java -version }}
    1. If java is installed (and it should be since we added it in Installing CentOS Step 8) then you will see
    2. Other wise run {{ sudo yum install java-1.7.0-openjdk }}
  2. Get Jenkins by running
    1. {{ wget -O /etc/yum.repos.d/jenkins.repo }}
    2. {{ rpm –import }}
  3. Install Jenkins by running {{ yum install jenkins }}
    1. Hit the [ y ] key and then [ Enter/Return ]  when prompted
    2. Your result should look like this
  4. Add Jenkins to Start Up by running {{ chkconfig jenkins on }}
  5. Start Jenkins by running {{ service jenkins start }}
  6. Ensure that Jenkins is running (default port is 8080) by running {{ netstat -tnlp | grep 8080 }}

Accessing Jenkins VM from Host

  1. Open up the firewall by running
    1. {{ firewall-cmd –zone=public –add-port=8080/tcp –permanent }}
    2. {{ firewall-cmd –reload }}
  2. Find the IP Address of the VM by running {{ hostname -I }}
  3. Open the settings for the VM
    1. See Creating the VM Steps 13 and 14 (above)
  4. Select Network
  5. Select Port Forwarding (if you don’t see it, select Advanced first)
  6. Select the Insert New Rule
  7. Enter the following:
    1. Host IP –
    2. Host Port – 8080
    3. Guest IP – from Accessing Jenkins VM from Host Step 2 (above)
    4. Guest Port – 8080
  8. Select OK
  9. On the host navigate to