问题
Here is my Jenkins pipeline that i am trying to execute. I am following this tutorial:
pipeline {
agent any
stages {
stage('one') {
parallel "first" : {
echo "hello"
},
"second": {
echo "world"
}
}
stage('two') {
parallel "first" : {
echo "hello"
},
"second": {
echo "world"
}
}
}
}
But the job fails with following message.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 4: Unknown stage section "parallel". Starting with version 0.5, steps in a stage must be in a steps block. @ line 4, column 9.
stage('one') {
^
WorkflowScript: 12: Unknown stage section "parallel". Starting with version 0.5, steps in a stage must be in a steps block. @ line 12, column 9.
stage('two') {
^
WorkflowScript: 4: Nothing to execute within stage "one" @ line 4, column 9.
stage('one') {
^
WorkflowScript: 12: Nothing to execute within stage "two" @ line 12, column 9.
stage('two') {
^
4 errors
Can someone please help me out why this is failing.
回答1:
You need to add a steps block after your stage declaration.
pipeline {
agent any
stages {
stage('one') {
steps {
parallel("first": {
echo "hello"
},
"second": {
echo "world"
}
)
}
}
stage('two') {
steps {
parallel("first": {
echo "hello"
},
"second": {
echo "world"
}
)
}
}
}
}
回答2:
You need to upgrade the Declarative Pipeline plugin on your Jenkins to Version 1.2 (Sept 21, 2017) or above
来源:https://stackoverflow.com/questions/43211530/jenkins-pipeline-with-parallel