5

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

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

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

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

the stageResult doesn't work for me.

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.

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

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

JHON SMITH
  • 103
  • 1
  • 1
  • 6
  • Does it happen every time? – CodeMonkey Sep 02 '19 at 05:59
  • yes, I tried it many times with different cases - same result – JHON SMITH Sep 02 '19 at 06:06
  • What version of [Pipeline Groovy](https://wiki.jenkins.io/display/JENKINS/Pipeline+Groovy+Plugin) plugin do have installed? – Technext Sep 02 '19 at 12:33
  • pipeline groovy - 2.74, I'll add it to the post – JHON SMITH Sep 02 '19 at 13:24
  • I am _not_ using the Jenkins _weekly_ release rather the LTS version `2.176.3` with `Pipeline: Groovy` version `2.74` and `Pipeline: Basic Steps` version `2.18`. It's working fine for me. If possible, you may give it a shot with the LTS one. – Technext Sep 02 '19 at 13:35
  • I'm downloading it right now, but I don't think it should be different from the weekly update – JHON SMITH Sep 02 '19 at 14:38
  • 1
    I am also little skeptical whether anything will change but doesn't harm to give it a try given the fact that it's working for me. Moreover, it will be easier to debug further if we have identical configuration. – Technext Sep 02 '19 at 17:08
  • I'm here with it, still doesn't work – JHON SMITH Sep 02 '19 at 20:19
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/198860/discussion-between-technext-and-jhon-smith). – Technext Sep 03 '19 at 06:02

1 Answers1

1

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

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

Technext
  • 7,887
  • 9
  • 48
  • 76
  • 2
    This issue also also indicate you need a core version of at least 2.164.3. https://issues.jenkins-ci.org/browse/JENKINS-57826 I can definitely say that 2.164.2 did not work for me, but 2.176.3 does. – philbert Sep 13 '19 at 09:24