Pipeline build not stopping when stage marked as failed

1,394 views
Skip to first unread message

Paul D'Ambra

unread,
Oct 4, 2018, 4:06:03 AM10/4/18
to Jenkins Users
I have a declarative Jenkins pipeline that in a parallel stage runs the dependency check plugin. With their support I have the plugin configured so that if a certain number of new vulnerabilities are detected it fails the build.

However, even though the build is marked as failed in Jenkins the pipeline is running on past that stage.

So, the build is marked as failed *and* the artefact has been deployed into an environment!

The plugin authors believe this is either the analysis plugin or Jenkins at fault. But I don't know how to investigate further. Can anyone here provide advice?

Thanks

Ramanathan Muthaiah

unread,
Oct 15, 2018, 4:56:37 AM10/15/18
to Jenkins Users
Most likely, you need this 'error'.

/Ram

Paul D'Ambra

unread,
Oct 15, 2018, 4:59:11 AM10/15/18
to jenkins...@googlegroups.com
Hi, thanks for the link?

I find the pipeline documentation a bit limited... there are no examples of usage in that link. Are you saying I need to "wrap" the dependency check stage in some way so that I can manually trigger the error signal when it fails?

Are you (or anyone) able to point me at an example of how that might work?

Thanks

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/tjxKjosOdqY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b91a6b50-360f-4bc3-9d7f-db78e86d92cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Bayer

unread,
Oct 15, 2018, 10:28:19 AM10/15/18
to jenkins...@googlegroups.com
Can you attach your Jenkinsfile? Thanks.

You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAKdKnDs7vZEZRMO9NkDu39KHtyQRbE8n3rRYJnYY3_5Um6V1NQ%40mail.gmail.com.

Paul D'Ambra

unread,
Oct 15, 2018, 10:56:05 AM10/15/18
to Jenkins Users
I think I've stripped out everything that I shouldn't share :)

not doing anything fancy. the dependency check runs and fails the build but the steps after it run even though it failed.
example_pipeline.jenkinsfile

Andrew Bayer

unread,
Oct 16, 2018, 3:57:45 AM10/16/18
to jenkins...@googlegroups.com
Hi -

Ah, ok, I think the issue is that dependencyCheckPublisher is just setting the build result to FAILURE, but the step itself isn't failing, per se - it's not throwing an error. The Pipeline will only stop running subsequent steps if there's an actual error - it doesn't check build status for that. So yeah, something like this after the dependencyCheckPublisher call would probably do the trick:

dependencyCheckPublisher(...)
script {
  if (currentBuild.result == "FAILURE") {
    error("Dependency Check failed")
  }
}

A.

Paul D'Ambra

unread,
Oct 16, 2018, 5:40:24 AM10/16/18
to jenkins...@googlegroups.com
I'll try that today! Thanks so much for your time!

P

Paul D'Ambra

unread,
Oct 16, 2018, 2:25:54 PM10/16/18
to jenkins...@googlegroups.com
That worked perfectly, thanks

P
Reply all
Reply to author
Forward
0 new messages