Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
/ jenkins-examples Public archive

Examples for settings up and using Jenkins in and with containers.

License

Notifications You must be signed in to change notification settings

kangasta/jenkins-examples

Repository files navigation

Warning

Deprecated: updated version of this guide is available on CI/CD Tutorials website.

Jenkins examples

This repository contains examples for settings up and using Jenkins in and with containers.

Note that by default each of the example docker compose configurations will create their own volumes for the data. This might not be what you want. In order to use the same volumes for every docker compose configuration, run docker compose with -p (or --project-name) option. This can also be done by setting COMPOSE_PROJECT_NAME environment variable:

export COMPOSE_PROJECT_NAME=jenkins

Installing Docker

See Get Docker for installation instructions.

If you use Docker a lot on Mac or Windows system, the recommended Docker Desktop is likely a good option for you. Note that, since January 2022, it has required paid subscription if used for commercial development.

Alternatively, Windows users can install Docker on top of WSL2. For Mac users there are alternatives, such as Colima, available.

Jenkins image with Docker-in-Docker support

In order to run Jenkins container with Docker-in-Docker support, cd into dind-jenkins directory and run docker compose up. See Dockerfile and docker compose.yml for the configuration details.

cd dind-jenkins/

# If you want to see logs in the current terminal
docker compose up --build

# Or if you want to run the container in the background
docker compose up --build --detach

The initial admin password can be easily printed with docker compose exec:

docker compose exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword

In order to get started the suggested plugins are often good a starting point. If you are planning to create pipeline projects with stages running in on-demand Docker containers, you will also need Docker Pipeline plugin. This can be installed through the Manage Jenkins > Manage plugins menu.

Other examples

For other examples, detailed descriptions are available in the directory specific README files: