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
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.