~/CloudSetup.In

Jenkins

CI/CD Jenkinsfile ● stable

Self-hosted automation server for building, testing, and deploying pipelines.

01 Overview

Jenkins runs Groovy-defined pipelines that check out code, build it, run tests, and deploy artifacts — triggered by commits, pull requests, or a schedule. It's plugin-driven, so it can talk to nearly any tool in a delivery chain.

→ official documentation

02 Installation

Pick a platform. Each step is copy-pasteable on its own.

01  Install Java (Jenkins requires a JDK)
sudo apt update
sudo apt install -y fontconfig openjdk-17-jre
02  Add the Jenkins repository
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
03  Install Jenkins
sudo apt-get update
sudo apt-get install -y jenkins
04  Enable and start the service
sudo systemctl enable --now jenkins
05  Get the initial admin password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
01  Install Java
sudo dnf install -y java-17-openjdk
02  Add the Jenkins repository
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
03  Install Jenkins
sudo dnf install -y jenkins
04  Enable and start the service
sudo systemctl enable --now jenkins
05  Get the initial admin password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
01  Install via Homebrew
brew install jenkins-lts
02  Start the service
brew services start jenkins-lts
Note — commands assume sudo privileges and an up-to-date package index. Pin a specific version in production rather than tracking latest.

03 Install script

The steps above bundled into a single idempotent shell script for provisioning boxes unattended.

install-jenkins.sh
Ubuntu/Debian target · safe to re-run · exits non-zero on failure
↓ download script

04 Cheatsheet

The commands reached for most often once Jenkins is installed.

CommandWhat it does
systemctl status jenkinsCheck service status (Linux)
java -jar jenkins-cli.jar -s URL list-jobsList jobs via the CLI
curl -X POST JENKINS_URL/job/NAME/buildTrigger a build via the REST API
Jenkinsfile: pipeline { agent any ... }Minimal declarative pipeline skeleton
sh 'command'Run a shell step inside a pipeline stage
archiveArtifacts artifacts: 'build/**'Save build output as an artifact