当前,当maven-job不稳定(黄色)时,我的管道失败(红色)。
node {
stage 'Unit/SQL-Tests'
parallel (
phase1: { build 'Unit-Tests' }, // maven
phase2: { build 'SQL-Tests' } // shell
)
stage 'Integration-Tests'
build 'Integration-Tests' // maven
}在本例中,作业Unit-Test的结果不稳定,但在流水线中显示为失败。
如何更改作业/管道/jenkins,使(1)管道步骤不稳定而不是失败,(2)管道的状态不稳定而不是失败。
我尝试添加MAVEN_OPTS参数-Dmaven.test.failure.ignore=true,但没有解决问题。我不确定如何将build 'Unit-Test'封装到可以捕获和处理结果的逻辑中。
使用this logic添加子流水线不会起到作用,因为没有从subversion签出的选项(该选项在常规的maven作业中可用)。如果可能的话,我不想使用命令行签出。
发布于 2016-08-02 19:30:22
无论步骤是不稳定的还是失败的,脚本中的最终构建结果都将失败。
默认情况下,您可以将propagate添加为false,以避免流失败。
def result = build job: 'test', propagate: false在流程的最后,您可以根据从" result“变量获得的结果来判断最终结果。
例如
currentBuild.result='UNSTABLE'下面是一个详细的How to set current build result in Pipeline示例
Br
时间
发布于 2016-08-03 14:10:53
吸取的经验教训:
currentBuild.result值不断更新管道,该值可以是SUCCESS、UNSTABLE或FAILURE build job: <JOBNAME>的结果可以存储在变量中。build status为variable.result.build job: <JOBNAME>, propagate: false将防止整个构建失败,right away.currentBuild.result can only get worse。如果该值以前为FAILED,且通过currentBuild.result = 'SUCCESS'接收到新状态SUCCESS,则它将保持为FAILED这是我最后用到的:
node {
def result // define the variable once in the beginning
stage 'Unit/SQL-Tests'
parallel (
phase1: { result = build job: 'Unit', propagate: false }, // might be UNSTABLE
phase2: { build 'SQL-Tests' }
)
currentBuild.result = result.result // update the build status. jenkins will update the pipeline's current status accordingly
stage 'Install SQL'
build 'InstallSQL'
stage 'Deploy/Integration-Tests'
parallel (
phase1: { build 'Deploy' },
phase2: { result = build job: 'Integration-Tests', propagate: false }
)
currentBuild.result = result.result // should the Unit-Test be FAILED and Integration-Test SUCCESS, then the currentBuild.result will stay FAILED (it can only get worse)
stage 'Code Analysis'
build 'Analysis'
}https://stackoverflow.com/questions/38713865
复制相似问题