What do I have
I am trying to run my jenkins pipeline using two different agents. I want to execute some process on the same agent but so far I am unable to do this because there are only 2 options for agent definition: I can do at top of pipeline or I can define the agent into each stage. I have this:
pipeline{
agent none
stages {
stage("Unit Testing"){
agent { label 'maven-build-slave' }
steps{
}
}
stage('Sonar Scanner - Quality Gates') {
agent { label 'maven-build-slave' }
steps{
}
}
stage("Integration"){
agent { label 'integration-slave' }
steps{
}
}
stage('SoapUI') {
agent { label 'integration-slave' }
steps{
}
}
}
}
In this case the main problem is that the code is pulled in every stage even when the agent is the same.
What do I want
I would like something like this:
pipeline{
agent none
stages {
agent { label 'maven-build-slave' }
stage("Unit Testing"){
steps{
}
}
stage('Sonar Scanner - Quality Gates') {
steps{
}
}
agent { label 'integration-slave' }
stage("Integration"){
steps{
}
}
stage('SoapUI') {
steps{
}
}
}
}
But the definition above is failing so I wonder if anyone knows a way to run several stages using same agent.