tlxxzj
2023-03-29 10:37:35 +08:00
def trigger1 = false
def trigger2 = false
def trigger3 = false
def causes = currentBuild.rawBuild.getCauses()
for(cause in causes) {
def desc = cause.properties.shortDescription
if (desc =~ "trigger1") {
trigger1 = true
} else if(desc =~ "trigger2") {
trigger2 = true
} else if(desc =~ "trigger3") {
trigger3 = true
}
}
pipeline {
agent any
stages {
stage("common") {
steps {
echo "common step"
}
}
stage("trigger1") {
when {
expression { trigger1 == true }
}
steps {
echo "trigger1 step"
}
}
stage("trigger2") {
when {
expression { trigger2 == true}
}
steps {
echo "trigger2 step"
}
}
stage("trigger3") {
when {
expression { trigger3 == true }
}
steps {
echo "trigger3 step"
}
}
}
}