Jenkins

The long-standing self-hosted automation server, with pipelines as code in Jenkinsfiles and a huge plugin ecosystem.

Intermediate · about 7 hours · difficulty 3/5

Learn first: Continuous Integration and Delivery

Jenkins is open source, self-hosted and extremely flexible. It predates cloud CI services, so it runs in countless enterprises, and maintaining it is a common DevOps task.

Architecture

  • A controller schedules work and hosts the UI; agents (static VMs, Docker containers or Kubernetes pods) run the builds.
  • Features come from plugins: Git, credentials, Kubernetes agents, Blue Ocean, and hundreds more. Plugins are both the strength and the main maintenance burden.

Pipelines as code

A Jenkinsfile in the repository defines the pipeline:

  • Declarative syntax: pipeline { agent ..., stages { stage('Test') { steps { ... } } } }, with post blocks for cleanup and notifications.
  • Scripted syntax is full Groovy, more powerful but harder to review.
  • Multibranch pipelines discover branches and pull requests automatically.
  • Shared libraries keep common steps in one versioned repository.

Running Jenkins well

  • Never run builds on the controller; use ephemeral agents.
  • Configure the instance as code with Configuration as Code (JCasC) and pin plugin versions.
  • Store secrets in the credentials store or an external vault, and bind them only to the steps that need them.
  • Back up JENKINS_HOME, keep plugins patched and restrict script approval.

Good enough to move on: you can run Jenkins in a container with Kubernetes or Docker agents, write a declarative multibranch Jenkinsfile, and explain how you would keep the instance patched and reproducible.

Key concepts

  • Controller and agents
  • Declarative Jenkinsfile
  • Multibranch pipelines
  • Credentials and secret binding
  • Shared libraries
  • Configuration as Code (JCasC)
  • Plugin management

Other options for this step

  • GitHub Actions: Build pipelines as YAML workflows triggered by repository events, using jobs, reusable actions, secrets and OIDC to the cloud.
  • GitLab CI/CD: Pipelines defined in .gitlab-ci.yml with stages, jobs, runners and environments, tightly integrated with GitLab's registry and security tools.

Mini project

Run Jenkins with JCasC in Docker, add an ephemeral Docker or Kubernetes agent, and create a multibranch pipeline that tests, builds an image and archives test reports.

Check yourself

Why should builds never run on the Jenkins controller itself?

Free resources