检查Jenkins构建中前一阶段的状态

bpzcxfmw  于 2023-08-03  发布在  Jenkins
关注(0)|答案(1)|浏览(123)

我想把表达式放入when条件中,以检查前一阶段的状态
我试过这个return currentBuild.getPreviousBuild()?.getResult()?.toString() != 'ABORTED' && currentBuild.getPreviousBuild()?.getResult()?.toString() != 'FAILURE' "但是这个表达式是用来检查previous的状态的buildnotstage
我也试过return currentBuild.getPreviousStageResult()?.getResult()?.toString() != 'ABORTED' && currentBuild.getPreviousBuild()?.getResult()?.toString() != 'FAILURE' "
但对我不起作用

brjng4g3

brjng4g31#

这里有一个例子来检查Jenkins管道中前一阶段的状态,也许这可以帮助你。

def previousBuild = currentBuild.getPreviousBuild()
    if (previousBuild) {
       def previousBuildResult = previousBuild.getResult()
       echo "Status of the previous build: ${previousBuildResult}"
    } else {
       echo "No previous build found."
    }

字符串

相关问题