Jenkins Pipeline Syntax
- Pipelines are written in Groovy language.
- Jenkins has defined certain Functions and blocks
- Jenkins has Developed DSL (Domain Specific Language)
Jenkins Pipeline – Important Definitions
- Node: Machine where Jobs get executed. Node is idenified by labels
node('LABEL') {
// your build config
}
- Stage: Complete build activity can be broken into multiple stages.
stage('<Stage name>') {
}
# Generally stages are part of nodes
node('MAVEN') {
stage('GIT') {
}
stage('BUILD'){
}
}
- shell: Executing shell in jenkins
sh <command>
sh 'mvn clean'
- git: Executes the git clone and pull operation. Refer here
git '<url>'
Quick Wins for generating pipelines.
- Create a jenkins pipeline project and navigate to pipeline section perform the below steps
- Try to generate pipeline steps for individual activities from Freestyle Projects.
- Exercise-1: Convert every Free-Style Project to Jenkins Pipeline
- Exercise-2: Create a pipeline project with parameters