Jenkins Cheat Sheet
Key commands and configurations for efficient Jenkins CI/CD management

A Jenkins cheat sheet covering essential concepts, commands, and configurations to help you get started and streamline your CI/CD processes.
Jenkins Cheat Sheet
1. Basic Concepts
Jenkins: An open-source automation server used to build, test, and deploy software.
Job: A single unit of work in Jenkins, such as building a project.
Pipeline: A sequence of steps that define the process of building, testing, and deploying code.
Node: A machine that Jenkins uses to execute jobs. The main server is known as the master node.
Agent: A machine that is configured to execute jobs for the Jenkins master.
2. Common Jenkins Commands
Start Jenkins:
bashCopy codesudo systemctl start jenkins # For systemd-based systems sudo service jenkins start # For older init.d systemsStop Jenkins:
bashCopy codesudo systemctl stop jenkins # For systemd-based systems sudo service jenkins stop # For older init.d systemsRestart Jenkins:
bashCopy codesudo systemctl restart jenkins # For systemd-based systems sudo service jenkins restart # For older init.d systemsCheck Jenkins Status:
bashCopy codesudo systemctl status jenkins # For systemd-based systems sudo service jenkins status # For older init.d systems3. Jenkins Configuration
Access Jenkins: Open your web browser and navigate to
http://<your-server-ip>:8080.Manage Jenkins:
- Go to Manage Jenkins for global configurations, plugin management, and system settings.
Manage Plugins:
Install Plugin: Go to Manage Jenkins > Manage Plugins > Available, search for the plugin, and click Install without restart.
Update Plugin: Go to Manage Jenkins > Manage Plugins > Updates.
4. Job Configuration
Create a New Job:
- Go to the Jenkins dashboard, click New Item, enter a name, select a job type (e.g., Freestyle project, Pipeline), and click OK.
Configure SCM (Source Code Management):
Git:
Credentials: Add GitHub credentials.
GitHub: Use the GitHub plugin for easier integration.
Build Triggers:
Poll SCM: Set up a cron-like schedule to poll the SCM for changes.
GitHub Hook Trigger: Set up a webhook on GitHub to trigger builds on code changes.
Build Steps:
Execute Shell: Run shell commands.
Invoke Ant/Gradle/Maven: Build using specific tools.
Execute Windows Batch Command: Run commands in a Windows environment.
Post-Build Actions:
Archive Artifacts: Specify files to archive after a build (e.g.,
*.jar).Send Email: Configure email notifications for build results.
5. Pipeline Configuration
Declarative Pipeline:
groovyCopy codepipeline { agent any stages { stage('Build') { steps { echo 'Building...' } } stage('Test') { steps { echo 'Testing...' } } stage('Deploy') { steps { echo 'Deploying...' } } } post { success { echo 'Pipeline succeeded!' } failure { echo 'Pipeline failed.' } } }Scripted Pipeline:
groovyCopy codenode { stage('Build') { echo 'Building...' } stage('Test') { echo 'Testing...' } stage('Deploy') { echo 'Deploying...' } catchError { echo 'Handling errors...' } }
6. Jenkins User Management
Add User:
- Go to Manage Jenkins > Manage Users and click Create User.
Assign Roles:
- Use Role-based Authorization Strategy plugin to manage roles and permissions.
7. Jenkins Security
Change Admin Password:
- Go to Manage Jenkins > Configure Global Security and update credentials.
Enable HTTPS:
- Configure Jenkins to use HTTPS by setting up a reverse proxy with Apache/Nginx or using Jenkins' built-in SSL support.
8. Backup and Restore
Backup Jenkins:
Manual Backup: Copy the Jenkins home directory (
/var/lib/jenkins).Automated Backup: Use plugins like ThinBackup for automated backups.
Restore Jenkins:
- Manual Restore: Copy the backup files to the Jenkins home directory and restart Jenkins.
9. Common Issues and Fixes
Jenkins Not Starting:
Check logs:
/var/log/jenkins/jenkins.log.Ensure there’s enough disk space and permissions are correct.
Job Fails to Build:
Check console output for error messages.
Verify SCM configurations and credentials.
10. Useful Jenkins Plugins
GitHub Integration Plugin: Connects Jenkins with GitHub.
Pipeline Plugin: Enables complex workflows using pipelines.
Blue Ocean: Provides a modern UI for Jenkins pipelines.
Slack Notification Plugin: Sends build notifications to Slack.



