如何解决-stageResult设置为FAILURE,但在jenkins中仍然获得成功 [英] how to fix - stageResult set to FAILURE but still get success in jenkins

查看:1073
本文介绍了如何解决-stageResult设置为FAILURE,但在jenkins中仍然获得成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个非常简单的管道, 它有一个阶段和一个步骤.

I'm trying to create a very simple pipeline, it has one stage and one step.

它使用我以自由样式创建的工作"build"(可以工作),但是我添加了一个错误(参数项目名称的值错误-"test3"而不是"test")

it uses the job 'build' I created as freestyle (which works) but I added an error (the parameter project name has a wrong value - 'test3' instead of 'test')

当我运行它时,它会保持绿色并发送成功"消息,尽管它失败了-如果我输入日志,则会看到以下内容:

when I ran it, it stay green and send "success" although it failed - if I enter the log I'll see this:

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\pipeline testing
[Pipeline] {
[Pipeline] stage
[Pipeline] { (1)
[Pipeline] catchError
[Pipeline] {
[Pipeline] build (Building build)
Scheduling project: build
Starting building: build #62
[Pipeline] }
ERROR: build #62 completed with status FAILURE (propagate: false to ignore)
[Pipeline] // catchError
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

我尝试使用新插件: catchError(buildResult:'SUCCESS',stageResult:'FAILURE')

I tried using the new plugin: catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE')

据我所知,应该将"FAILURE"发送给阶段,将"SUCCESS"发送给整个构建.

which as I understand is suppose to send "FAILURE" for stage and "SUCCESS" for the build as a whole.

stageResult对我不起作用.

the stageResult doesn't work for me.

我尝试为构建作业:"添加"propagate:true" 但这也无济于事. 这是管道本身:

I tried adding "propagate: true" for the "build job:" but it didn't help either. this is the pipeline itself:

pipeline {
    agent any
    stages 
    {
        stage('1') 
        {
            steps 
            {
                catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE')
                {
                    build job: 'build',parameters: [string(name: 'Project_Name', value: 'test3'), 
                    string(name: 'Environment_Name', value: 'Dev_Env_1')]
                }
            }
        }
    }
}

这是我真正需要的功能,但是它无法正常工作. 每次失败都会让我成功,而不是失败并继续进行项目.

This is a really "on the point" feature for what I need but it refuses to work. Instead of getting a failure and continuing with the project I get success each time.

它确实会继续(如果我有更多的阶段),但是问题是我需要将其变成红色,并告诉我阶段失败了,而不是绿色表示成功.

It does continue (if I have more stages) but the issue is that I need it to be red and tell me the stage failed instead of green with success.

我确实将詹金斯版本更新为2.192 流水线槽为2.74 和2.18的管道:基本步骤"插件

I did updated my jenkins version to 2.192 pipeline groovy is 2.74 and "pipeline: basic steps" plugin to 2.18

最终的解决方案是更新所有其余的插件

the solution in the end was to update all the rest of the plugins

推荐答案

除了具有以下版本的插件外,似乎(如聊天中所讨论的)还有其他一些插件也需要更新.

Besides having following versions of plugins, seems (as discussed on chat) there were other plugins as well which had to be updated.

Pipeline Basic Steps: 2.18
Pipeline: Groovy version 2.74
Pipeline: Basic Steps version 2.18

更新插件"部分的(http://<JENKINS_HOME>/pluginManager/)Updates选项卡中的所有插件后,问题已解决.

After updating all the plugins in Plugins section's (http://<JENKINS_HOME>/pluginManager/) Updates tab, issue got resolved.

这篇关于如何解决-stageResult设置为FAILURE,但在jenkins中仍然获得成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆