Jenkins Cheat Sheet
Jenkins Automation Guide
This Jenkins cheat sheet provides essential information for DevOps engineers and developers looking to streamline their CI/CD workflows. It covers key aspects of Jenkins, including build scheduling and understanding cron expressions.
Build Scheduling with Cron Expressions
Jenkins utilizes cron expressions for scheduling build jobs. These expressions define when a job should run automatically. Below are common examples and their meanings:
# Run every hour
H * * * *
# Run every 15 minutes
H/15 * * * *
# Run at 9:00 AM every weekday
H 9 * * 1-5
# Run at 2:30 PM on the 1st and 15th of every month
H 14 1,15 * *
The 'H' symbol in Jenkins cron expressions is used for 'hash', which distributes the load across Jenkins agents. It's a more advanced way to schedule jobs compared to traditional cron.
Understanding Cron Syntax
A cron expression consists of five fields, separated by spaces:
- Minute (0-59)
- Hour (0-23)
- Day of Month (1-31)
- Month (1-12)
- Day of Week (0-7, where 0 and 7 are Sunday)
Resources for Cron Expressions
- For a deeper understanding of Jenkins' specific cron implementation, refer to Jenkins Build Periodically on Stack Overflow.
- General information on cron can be found at Wikipedia: Cron.
- To learn more about scheduling jobs in Jenkins, see How to schedule jobs in Jenkins?.
Key Jenkins Concepts
Jenkins is a powerful open-source automation server that enables developers to reliably build, test, and deploy their software. Its flexibility allows for integration with a wide range of tools and technologies, making it a cornerstone of many DevOps practices.
Continuous Integration and Continuous Delivery (CI/CD)
Jenkins is instrumental in implementing CI/CD pipelines. CI focuses on frequently merging code changes into a central repository, followed by automated builds and tests. CD extends this by automating the release of software to production or staging environments.
Pipelines as Code
Jenkins supports defining pipelines as code using Groovy scripts (Jenkinsfile). This allows pipeline configurations to be version-controlled, reviewed, and managed alongside the application code, promoting consistency and reproducibility.