Jenkins Pipelines
A Jenkinsfile
is a configuration file that describes the workflow or pipeline
used to build and deliver a piece of software.
By using a Jenkinsfile
we have a description of each step involved, and by storing this in git, we have a historical
record of the workflow.
Jenkins can run the steps described in the file.
Stages
A pipeline can have multiple stages, Jenkins will report on the duration each stage takes.
The starting template below contains three stages.
pipeline {
agent any
stages {
stage('build') {
steps {
sh "echo building..."
sh "echo building more..."
}
}
stage('test') {
steps {
sh "echo testing..."
}
}
stage('deploy') {
steps {
sh "echo deploying..."
}
}
}
}
Example job configuration
To configure a pipeline job in Jenkins, login then navigate to a folder, and click on New Item
.
Enter a name, then choose Pipeline
as the project type, then click OK.

Create a pipeline job
The next step is configuration.
Click on the Pipeline
tab and paste the script above into the text area. Click on Save.

Add the pipeline script
It is possible and prudent to pull the Definition
from source control such as git.
Try it out by clicking on Build Now
. Once it finishes it will report on how long each stage took.

Stage View
You can also click on each stage of an individual build and view the logs. The logs will contain output and timings of each step.