In Jenkins 2.138.3 there are two different types of pipelines.
Declarative and Scripted pipelines.
"Declarative pipelines is a new extension of the pipeline DSL (it is basically a pipeline script with only one step, a pipeline step with arguments (called directives), these directives should follow a specific syntax. The point of this new format is that it is more strict and therefore should be easier for those new to pipelines, allow for graphical editing and much more.
scripted pipelines is the fallback for advanced requirements."
jenkins pipeline: agent vs node?
Here is an example of a Declarative Pipeline:
pipeline {
agent any
environment {
//Use Pipeline Utility Steps plugin to read information from pom.xml into env variables
IMAGE = readMavenPom().getArtifactId()
VERSION = readMavenPom().getVersion()
}
stages {
stage('Test') {
steps {
echo "${VERSION}"
}
}
}
}
Example of Scripted Pipeline
node('master') {
stage('Test') {
IMAGE = readMavenPom().getArtifactId()
VERSION = readMavenPom().getVersion()
echo "IMAGE: ${IMAGE}"
echo "VERSION: ${VERSION}"
}
}
Here are some good links:
Declarative
https://github.com/jenkinsci/pipeline-examples/blob/master/declarative-examples/jenkinsfile-examples/mavenDocker.groovy
Scripted
https://bulldogjob.com/articles/726-exploring-jenkins-pipelines-a-simple-delivery-flow