I see on the declarative pipeline that it is really through the "post" section very simple with conditions such as "always", "failure", ...:
https://jenkins.io/doc/book/pipeline/syntax/#post
But with Scripted Pipeline there are no examples of how to do this:
This link gives an example, but only for the "always" condition
https://jenkins.io/doc/book/pipeline/jenkinsfile/#handling-failures
I see these documents on how to set this result, but I do not understand, because with Declarative Pipeline you do not need to install it manually, the commands provided by the plugins handle this for you.
https://support.cloudbees.com/hc/en-us/articles/218554077-How-to-set-current-build-result-in-Pipeline
Can anyone help me with this?
For example, if I do this:
node {try {error "Test error"} catch (ex) {echo 'Error handleled'}}
It does not call the FAILURE build status automatically, and I do not see the echo. Why?
Your piece of code works as expected:
node { try { error 'Test error' } catch (ex) { echo 'Error handled' } }
gives:
[Pipeline] node Running on maître in /var/lib/jenkins/workspace/test-pipeline2 [Pipeline] { [Pipeline] error [Pipeline] echo Error handled [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS
Explanations:
, catch. catchError . .: https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-catcherror-code-catch-error-and-set-build-result
Source: https://habr.com/ru/post/1672584/More articles:Android Studio 2.3 does not show stacktrace exception - androidForm Objects in Rails - ruby | fooobar.comRails forms an object with embossed rails, and collections do not work or do not check - ruby | fooobar.comIs it good practice to reference each constant line? - c ++How to run guetzli on all jpeg images in a folder and subfolders - image-processingSQLite: GROUP BY без агрегата - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1672586/how-to-copy-files-to-ouptut-directory-from-a-referenced-nuget-package-in-net-core-csproj&usg=ALkJrhjuLyfybcRu1K32_oVFqTQFvgWJKQHow to combine any appearance of a symbol, except when it occurs twice? - javaDevelopment and implementation of Vuejs application with django - djangoJavascript: How to get property of an object using an Array string? - javascriptAll Articles