运行Jenkins ver。 2.89.2
采用声明性管道。
pipeline {
agent none
stages {
stage('init') {
steps {
script {
currentBuild.result = 'SUCCESS'
//currentBuild.result = 'UNSTABLE'
//currentBuild.result = 'FAILURE'
//currentBuild.result = 'ABORTED'
}
}
}
}
post {
always {
echo "Always: $currentBuild.currentResult vs $currentBuild.result"
}
changed {
echo "Changed: $currentBuild.currentResult vs $currentBuild.result"
}
success {
echo "Success: $currentBuild.currentResult vs $currentBuild.result"
}
unstable {
echo "Unstable: $currentBuild.currentResult vs $currentBuild.result"
}
failure {
echo "Failure: $currentBuild.currentResult vs $currentBuild.result"
}
aborted {
echo "Aborted: $currentBuild.currentResult vs $currentBuild.result"
}
}
}
多次运行SUCCESS会产生一个输出(在后续运行时不会进入更改块):
[Pipeline] echo
Always: SUCCESS vs SUCCESS
[Pipeline] echo
Success: SUCCESS vs SUCCESS
但是,在运行任何其他状态(不稳定,故障等)时始终输入change
块
[Pipeline] echo
Always: UNSTABLE vs UNSTABLE
[Pipeline] echo
Changed: UNSTABLE vs UNSTABLE
[Pipeline] echo
Unstable: UNSTABLE vs UNSTABLE
我希望第一次"改变"进入更改块的状态,但不是后续的状态。这适用于SUCCESS结果。为什么不通过其他结果?