in Education by
I want when some of the stages in the Jenkins pipeline get error then to have some options like asking for input, or print some message. For example in this pipeline error is in the stage 2 by executing not existing 'shit' (sh 'asdasd') node('master') { try { stage('stage1') { echo 'stage 1 succeeeded' } stage('stage2') { echo '1st task of stage 2 is cool' // this is the ERROR sh 'asdasd' } } finally { echo 'SUCCESS' } } My question is how ask for input IF error popup if some of the stages? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
There are several posts that show how to capture errors using try - catch blocks inside anything, stages in this case: see e.g. this or this What you want additionally is define an user input in the "catch" case. In general, that is a bad idea, see this article describing why user inputs are dangerous in pipelines. But the article also offers a solution including timeouts. If really needed, code can be something like... node('master') { try { stage('stage1') { echo 'stage 1 succeeeded' } stage('stage2') { try { echo '1st task of stage 2 is cool' // this is the ERROR sh 'asdasd' } catch (errScript) { try { timeout(time: 60, unit: 'SECONDS') { // set desired timeout userInput = input( id: 'userInput', message: 'Press OK to continue', ) } } catch (err) { // timeout reached or user input def user = err.getCauses()[0].getUser() if('SYSTEM' == user.toString()) { // SYSTEM means timeout. // Do your timeout thing } else { // Evaluate your user input action } } } // catch (errScript) } } finally { echo 'SUCCESS' } Run code snippetExpand snippet

Related questions

0 votes
    How do I get something taken off my credit report?...
asked Oct 10, 2020 in Credit by Editorial Staff
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do: when an element with any class listed in an array is clicked, the class ( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am trying to fetch some data from the GitHub GraphQL but I get a GaphQLError. I have tried the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    If we need to inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how can we do that?...
asked Jan 16, 2021 in Technology by JackTerrance
0 votes
    My question may be silly but I've been trying several ways and I still can't do what I want, i. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    How to get the Jenkins version programmatically in Jobs/Pipelines or nodes other than master?...
asked Sep 14, 2021 in Technology by JackTerrance
0 votes
    Russia is a powerful state on the global stage Do you agree with the view Explain with reasoning? Select the correct answer from above options...
asked Aug 3, 2022 in Education by JackTerrance
0 votes
    State true or false. When you have finished your work in the IMG or ABAP Workbench, or have reached a certain stage, you can release the request. A. True B. False...
asked Feb 20, 2023 in Technology by JackTerrance
0 votes
    How to do Global Tools Configuration in Jenkins?...
asked Sep 14, 2021 in Technology by JackTerrance
0 votes
    How to do Global Tools Configuration in Jenkins?...
asked Jul 17, 2021 in Technology by JackTerrance
0 votes
    How do you store credentials in Jenkins securely?...
asked Jul 16, 2021 in Technology by JackTerrance
...