Managed to successfully run integration tests in parallel on the same node and I now I would like to distribute them across different nodes. In the example below I want stages IT 1 and IT 2 to run on different nodes leaving IT 3 to run on the original node. Tried several combinations by using node as a parent of stage('IT 1') and node as a child but I get syntax errors for both. What is the proper syntax to achieve this?
pipeline {
agent { label '!master' }
stages {
stage('Integration Tests') {
parallel {
stage('IT 1 (slow)') {
steps {
sh 'run-it-1.sh'
}
}
stage('IT 2 (slow)') {
steps {
sh 'run-it-2.sh'
}
}
stage('IT 3 (quick)') {
steps {
sh 'run-it-3.sh'
}
}
}
}
}
}
Edit: Using label instead of node works for declarative pipelines. Example below:
stage('IT 1 (slow)') {
agent { label '!master' }
steps {
sh 'run-it-1.sh'
}
}
Since Declarative version 1.2, you can directly declare the kind of agent you want to use for each parallel stages : https://jenkins.io/blog/2017/09/25/declarative-1/
Not tested this specific use case, but I assume that if you don't declare any agent{} for stage "IT 3", it will be executed on the original node.
Hopefully it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With