HOWTO
- Configure agents https://www.howtoforge.com/tutorial/ubuntu-jenkins-master-slave/
- Agent x node https://stackoverflow.com/questions/42050626/jenkins-pipeline-agent-vs-node
- Declarative pipeline syntax https://www.jenkins.io/doc/book/pipeline/syntax/
- Pipeline example https://www.jenkins.io/doc/pipeline/examples/
- https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-multiple-agents
Configure Jenkins agent
agent
The agent
section specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the agent
section is placed. The section must be defined at the top-level inside the pipeline
block, but stage-level usage is optional.
- label
- Execute the Pipeline, or stage, on an agent available in the Jenkins environment with the provided label. For example:
agent { label 'my-defined-label' }
- node
agent { node { label 'labelName' } }
behaves the same asagent { label 'labelName' }
, butnode
allows for additional options (such ascustomWorkspace
).
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'
}
}
}
}
}