While working on my multi-part series covering the Job-DSL plugin for Jenkins, I wanted to get my own Jenkins instance stood up so that I could test & play without affecting any of our shared instances. That’s exactly what’s being covered here. Getting a brand new, personal Jenkins instance up and running so that we can test DSL code without affecting anyone else. I’m going to be using Docker for this walk thru and I can’t believe how easy/simple the whole process was!! So please, if you’re following along in my DSL exploration – start here and get your own environment to destroy!!
Assuming you have Docker already installed, let’s go ahead and pull the latest Jenkins image which amounts to just this line of code:
docker pull jenkins
And once the image is available locally, we can go ahead and run it like this:
docker run -p 8080:8080 -p 50000:50000 jenkins
In the latest version (I think all versions starting at 2.x), Jenkins requires an admin password. The initial admin password will be located in the output somewhere. I've highlighted it here, although yours will absolutely be different:
Copy the initial admin password because you'll need it when trying to login to your Jenkins instance. My PowerShell session isn't returned to me, but that's ok. When I see the line "
setting agent port for jnlp" I know that I'm ready to go. In my browser, all I need to do is navigate to
localhost:8080 where I should see a Jenkins login screen. Remember that admin password you copied to your clipboard? This is where you'll use it. At the next screen, I'm just going to select "Install Suggested Plugins" for this demo:
After the recommended plugins are installed, I'll install the job-dsl & greenballs plugins via the "Manage Jenkins" >"Manage Plugins" screen. Greenballs? Why must we have that for the demo? Because, in my mind, a representation of a successful job is (and always will be) green. I just wish they'd change the default color of successful runs from blue to green so I didn't need to install an additional plugin.
That's it! Surprisingly, I was up and running in just a few minutes with very little Docker experience! I slotted a couple of hours for this exercise figuring the learning curve on Docker alone would drag me down a bit. Nope! Now I have a sandbox Jenkins instance to experiment on without risking a bad script taking down my production Jenkins instance (or even my test instance).