Back to blog

Docker-based Jenkins quick start examples

Ashutosh Saxena
Ashutosh Saxena
August 24, 2023

Jenkins GSoC

About the Project

The aim of my project was to tackle the challenges and intricacies that users frequently encounter when configuring Jenkins with Docker. The current process comprises numerous daunting steps associated with security risks. My objective was to resolve this issue using Docker Compose by crafting a Docker Compose file and conducting regular testing. Furthermore, the project included the creation of user-friendly documentation, tutorials, and a streamlined Gitpod setup accessible with just one click.

What will change in Jenkins after this project:

  • Previously, users had to follow six intimidating steps to install Jenkins with Docker, which appear as follows:

    Creating docker in docker container

    Building dockerfile

    Creating container from previous image

  • After this project, users will only need two commands: git clone URL and docker-compose up -d.

  • This also applies to tutorials that utilize the same Docker setup as mentioned above. After cloning the repository, users will only need to execute docker-compose up -d <keyword>.

  • Additionally, users can take advantage of a one-click setup using Gitpod to easily experience Jenkins.

  • Currently, these Docker Compose files undergo regular testing via GitHub Actions. We plan to transition this process to Jenkins in the near future.

Phase 1

During Phase 1, we aimed to accomplish this objective using scripts. We developed jenkins_init.sh and jenkins_teardown.sh scripts to initiate and stop the containers. Additionally, we crafted scripts for SSH key generation and the cloning/forking of repositories.

Throughout Phase 1, I gained insights into:

  • Optimal Git and GitHub practices

  • Effective conflict resolution in merging

  • The structure of the Jenkins file system

  • Creation and utilization of Docker Compose files

  • Crafting of shell scripts

  • Building Dockerfiles

  • Understanding of SSH key mechanisms

  • Navigating the functionality of Gitpod

  • Composing technical documentation

Phase 2

In Phase 2, our focus shifted towards integrating Windows as well, given that the shell scripts from Phase 1 were incompatible without Windows Subsystem for Linux (WSL). During this phase, we uncovered the utility of Docker Compose profiles, which turned out to be an excellent solution. These profiles allowed the tutorials to function similarly to our previous scripts, employing designated keywords.

A crucial aspect of the project was automated testing, which introduced me to GitHub Actions, a tool I hadn’t previously experienced. GitHub Actions were employed to test the functionality of Docker Compose files, facilitate the uploading of Docker images to Docker Hub, perform plugin updates, and manage other various tasks.

During Phase 2, my learning encompassed:

  • Docker Compose files

  • GitHub Actions

  • The Jenkins Remote Access API

Next Steps

The upcoming steps for the project involve:

  • Full integration into jenkins.io.

  • Transitioning from GitHub Actions to jenkins.ci.

  • Incorporating the repository into Hacktoberfest with "good first issues" to engage beginner contributors.

  • As a stretch goal, expanding the project with additional tutorials.

Acknowledgments

I am grateful for the guidance and support provided throughout this project from my mentors Bruno Verachten, Bervianto Leo Pratama, and Jean-Marc Meessen.

Conclusion

In conclusion, participating in GSoC 2023 was an incredible experience that allowed me to learn new skills and contribute to an open-source project. I am grateful for the opportunity and would like to thank my mentors and the Jenkins community for their support and guidance. I look forward to continuing to contribute.

About the author

Ashutosh Saxena

Ashutosh Saxena

Ashutosh is an IT undergraduate from India. He loves idea of open-source and began his journey with Jenkins during Hacktoberfest 2022. Ashutosh is interested in the field of DevSecOps and is learning new things everyday. He was selected as a Google Summer of Code 2023 contributor to work on the project “Docker-based Jenkins quickstart examples”. Ashutosh is excited to continue his journey in the world of technology and open-source development