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
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/initialAdminPassword2. Describe the desired state
A declarative Jenkinsfile with stages and a post block.
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.
@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.