Yesterday, I tried using sequential stages. I have a pipeline consisting of 2 distinct parts, let's say JAVA PART and DOCKER PART, each with a different agent and several stages. Thus, I grouped them into two stages, assigned an agent and well, it worked as expected. Things went south when I wanted to use parallel stages inside JAVA PART:
pipeline {
agent none
stages {
stage("JAVA PART") {
agent A
stages {
stage("Java one") {
steps {
echo "Java one"
}
}
stage("Java two") {
parallel {
stage("Java parallel one") {
steps {
echo "Java parallel one"
}
}
stage("Java parallel two") {
steps {
echo "Java parallel two"
}
}
}
}
stage("Java three") {
steps {
echo "Java three"
}
}
}
}
stage("DOCKER PART") {
agent B
steps {
echo "Docker one"
}
}
}
}
I ended up with
Parallel stages or branches can only be included in a top-level stage.
I wonder what the rationale behind this restriction is, because when I switch from parallel to stages and make it serial, everything is fine.
pipeline {
agent none
stages {
stage("JAVA PART") {
agent A
stages {
stage("Java one") {
steps {
echo "Java one"
}
}
stage("Java two") {
stages {
stage("Java parallel one") {
steps {
echo "Java parallel one"
}
}
stage("Java parallel two") {
steps {
echo "Java parallel two"
}
}
}
}
stage("Java three") {
steps {
echo "Java three"
}
}
}
}
stage("DOCKER PART") {
agent B
steps {
echo "Docker one"
}
}
}
}
|