Jenkins · Declarative pipeline basics
Run a stage conditionally
Skip a stage unless a condition holds.
stage('Deploy') {
when { branch 'main' }
steps { sh './deploy.sh' }
}
Official Jenkins documentation
More declarative pipeline basics commands
- A minimal Jenkinsfile
- Run in a Docker container
- Set environment variables
- Set pipeline options
- Ask for parameters
- Run on a schedule
All declarative pipeline basics commands · Jenkins cheatsheet