A component of Pipeline Plugin.
Pipeline steps locking agents and workspaces, and running external processes that may survive a Jenkins restart or agent reconnection.
The nodes and processes plugin also called workflow durable task steps locks jenkins agents with the processes running on them, thereby adding durability to workflows. This ensures Pipelines can resume after an unforseeable restart.
The plugin provides a ws
step to allocate a workspace, however, this is created automatically using the node
step. The Pipeline Syntax Snippet Generator guides the user on usage, practical examples and more information.
A node is the machine on which Jenkins runs, it is part of the Jenkins environment and is capable of executing a Pipeline.
The agent
syntax is equivalent to the node
syntax except in different spheres. agent is a declarative syntax that is used to specify the executor and workspace on which the Pipeline will be executed while node is scripted syntax that is used to execute Pipelines (and any stages contained within it), on any available agent/node
A process in Jenkins can be defined as the continuous integration and continuous delivery of builds, tests, analysis, and deployment of projects and any other scenario that can be automated. The steps in these processes are documented in the jenkinsfile which can be created manually or added automatically using Blue Ocean.
Examples of nodes and processes in respect to declarative and scripted pipeline
-
A scripted pipeline example can be found here
-
A declarative pipeline example can be found here, refer to the Pipeline Syntax Snippet Generator and for more information
It is possible to run Jenkins pipeline on multiple agents. Pipelines that can run on low resource can be paired with equal powered agents and high resource agents with equal powered pipelines to avoid unnecessarily long build time.
A declarative pipeline with multiple agents:
pipeline {
agent none
stages {
stage('Build') {
agent any
steps {
checkout scm
sh 'make'
stash includes: '**/target/*.jar', name: 'app'
}
}
stage('Test on Linux') {
agent {
label 'linux'
}
steps {
unstash 'app'
sh 'make check'
}
post {
always {
junit '**/target/*.xml'
}
}
}
stage('Test on Windows') {
agent {
label 'windows'
}
steps {
unstash 'app'
bat 'make check'
}
post {
always {
junit '**/target/*.xml'
}
}
}
}
}
A scripted pipeline with multiple agents
stage('Test') {
node('linux') {
checkout scm
try {
unstash 'app'
sh 'make check'
}
finally {
junit '**/target/*.xml'
}
}
node('windows') {
checkout scm
try {
unstash 'app'
bat 'make check'
}
finally {
junit '**/target/*.xml'
}
}
}
Refer to this article for a detailed explanation.