Jenkins Job DSL Playground Docker image

I have been using Jenkins Job DSL Playground since I realized that DSL is the best option for managing Jenkins jobs. If you have a lot of them, changing anything can be very painful without any automation. Jenkins DSL Plugin allows transforming configuration into the code and store that in the Git repository. But, you know, sometimes changes are very complex and you can make a mistake, hence I needed something that helps me. And I found it – Jenkins Job DSL Playground. It was obvious for me, that I can also use a docker image, but I couldn’t find any ready solution. So, since there is no such tool, I decided to create that! This is how Jenkins Job DSL Playground Docker image arose!

If you’re not familiar with Jenkins Job DSL Playground, don’t worry. I have in my plans a small tutorial how to use that fantastic tool. But today I want only to focus on a docker image. How you can build that or just use that with the Docker Hub. In both cases, I assume you have Docker installed on your machine.

How to build Jenkins Job DSL Playground Docker image?

If you want to build (and/or make some changes before in Dockerfile), clone my repository from GitHub and get into the downloaded directory.

Jenkins Job DSL Playground docker image repository

Now you can make necessary changes and/or just run the following command:

It will result in a docker image tagged as job-dsl-playground, stored in your system.

How to use Jenkins Job DSL Playground Docker image?

The project is stored on Docker Hub, what allows you to run docker directly from Docker Hub. Just type the following command:

where:

  • -p 5050:5050 – it will bind container’s port 5050 to your machine’s port 5050
  • -v ~/.gradle:/home/gradle/.gradle – it will mount container’s /home/gradle/.gradle (where container stores dependencies downloaded by gradle) to ~/.gradle directory on your machine – you can choose another place on your local machine
  • -n my-dsl-playground – it’s just the name so that you can identify the container

During the first run, gradle will download all dependencies to the /home/gradle/.gradle inside the container. So due to that, if you don’t mount that volume to your local filesystem, docker will download all dependencies at every run. Volume mounting guarantees that dependencies will be accessible and next runs will be much faster. At the end you should only open your web browser and type:

Of course, you should replace a port number if you choose another one. Now you can use Jenkins Job DSL Playground Docker image locally (or on your server with your own docker containers).

Some details

I was very surprised when I noticed, that there is no Jenkins Job DSL Playground Docker image. I was looking for it in many places – GitHub, Docker Hub and just on the Internet. Without success. Maybe I’ve missed something and that image is anywhere on the web, but… I just couldn’t find anything. The image which I created is based on the gradle:alpine image. Thanks to that, the whole image is small – it’s only 207 MB – and has everything necessary to run the application. I chose cloning repository into the docker image for one, main reason: It’s much simpler to update than using the COPY and cloning the application repository outside of the image. When you run docker, you just simply call gradlew run, that begins the gradle build according to the application configuration. The final effect is a Ratpack server with the Jenkins Job DSL Job Playground.

You can find the Docker image on Docker Hub:

Jenkins Job DSL Playground Docker image

I’m not the author of the application – Jenkins Job DSL Playground is written and maintained by sheehan. This docker image uses his repository. If you have any questions about Jenkins Job DSL Playground Docker image – please feel free to ask in the comment section. Also, you can write me an e-mail. Any issues should be reported in the GitHub issue section.

 

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.