← All insightsAutomation

Automating Jenkins from scratch

CodeWizard Academy · 23 July 2026 · 3 min read · Intermediate

Anything you do to Jenkins twice should be automated. This walks the path from a manual install to a repeatable, pipeline-driven setup.

1. Install it reproducibly

bash
docker run -d --name jenkins -p 8080:8080 -p 50000:50000 \
  -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword

2. Describe the desired state

A declarative Jenkinsfile with stages and a post block.

groovy
pipeline {
  agent any
  options { timeout(time: 20, unit: 'MINUTES') }
  stages {
    stage('Build') { steps { sh 'make build' } }
    stage('Test')  { steps { sh 'make test' } }
    stage('Deploy') {
      when { branch 'main' }
      steps { sh 'make deploy' }
    }
  }
  post {
    failure { echo 'Build failed - notifying team' }
    always  { junit 'reports/**/*.xml' }
  }
}

3. Run it from CI

Reusable logic belongs in a shared library, called from the Jenkinsfile.

groovy
@Library('acme-shared') _
standardPipeline(language: 'node', deploy: true)

Want senior help putting Jenkins to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult