Reputation: 73
I'm learning the Jenkins pipeline scripts. I'm now at the step that I want to do things in parallel. I tried a few syntaxes, but everytime I get
Nothing to execute within stage "Static Checks"
Here is my last attempt:
stage('Static Checks'){
steps{
parallel ("cpp_check":{
node('cppcheck'){
bat '%CPP_CHECK%\\cppcheck.exe -j 4 --quiet --enable=warning,performance,portability --inline-suppr --xml --xml-version=2 src\\Cables src\\PD src\\DataAccess 2> cppcheck-result.xml'
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'cppcheck-result.xml', unHealthy: ''
}
}, "clock"{
node('clock'){
bat '%CLOCK%\\cloc-1.72.exe --by-file --xml --exclude-ext=pro,pri,ts --out=cloc.xml src/'
}
}
)
}
}
At the moment, it is really confusing because there are so many tutorials with different (old) syntaxes. Most of them are not working with the actual plugin.
So in general the questions are:
Upvotes: 1
Views: 1065
Reputation: 4026
@burnettk Nowadays you can put stages in parallel, but only at the top level. Modifying your Jenkinsfile, it would look something like this:
pipeline {
agent { label 'docker' }
stages {
stage('Pre-Parallel-Work) {
steps {
echo Just an example
}
}
stage('Static Checks') {
parallel {
stage('cpp_check') {
node { label 'cpp-check' }
steps {
bat '%CPP_CHECK%\\cppcheck.exe -j 4 --quiet --enable=warning,performance,portability --inline-suppr --xml --xml-version=2 src\\Cables src\\PD src\\DataAccess 2> cppcheck-result.xml'
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'cppcheck-result.xml', unHealthy: ''
}
}
stage('clock') {
node { label 'clock' }
steps {
bat '%CLOCK%\\cloc-1.72.exe --by-file --xml --exclude-ext=pro,pri,ts --out=cloc.xml src/'
}
}
}
}
stage('Post-Parallel-Work) {
steps {
echo Just an example
}
}
}
}
The stages 'cpp-check' and 'clock' would be done in parallel.
Upvotes: 0
Reputation: 14047
you're missing a colon after "clock"
, dogg. you were really fricking close. :) here's the full validating Jenkinsfile:
pipeline {
agent { label 'docker' }
stages {
stage('Static Checks') {
steps {
parallel (
"cpp_check": {
node('cppcheck') {
bat '%CPP_CHECK%\\cppcheck.exe -j 4 --quiet --enable=warning,performance,portability --inline-suppr --xml --xml-version=2 src\\Cables src\\PD src\\DataAccess 2> cppcheck-result.xml'
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'cppcheck-result.xml', unHealthy: ''
}
},
"clock": {
node('clock') {
bat '%CLOCK%\\cloc-1.72.exe --by-file --xml --exclude-ext=pro,pri,ts --out=cloc.xml src/'
}
}
)
}
}
}
}
you must include your parallel tasks as steps inside one stage, as far as i know; you cannot run stages in parallel. enjoy pipelines. :)
Upvotes: 4