Is there a way to insert a manual approval in Jenkins 2 pipelines?











up vote
14
down vote

favorite
3












Jenkins 2 has pipelines has a first class citizen. However, in the examples the tasks seem to be executed as a single sequence:



node {
// Mark the code checkout 'stage'....
stage 'Checkout'

// Get some code from a GitHub repository
git url: 'git@github.com:elifesciences/elife-bot.git'

// Mark the code build 'stage'....
stage 'Build'
echo "Unit tests will run here"

stage "Production"
echo "Deploying to production environment"
}


For deployment into production system it's often useful to require manual approval; is there a way to insert a manual button to press inside a pipeline?



I have been looking for possible steps to accomplish this on the docs, to no avail.










share|improve this question






















  • I don't know Jenkins, but isn't there a way to split your build plan into several steps, and having some of these steps be run only on a "manual trigger"?
    – tiktak
    May 5 '16 at 16:06










  • Best partial solution so far: an input step in the pipeline which stops and asks the user for input (or to abort the build). However, the stage and the status indicator keeps flashing while I wanted a stable state (e.g. you get into it Friday afternoon and decide to deploy on Monday.)
    – giorgiosironi
    May 6 '16 at 12:19















up vote
14
down vote

favorite
3












Jenkins 2 has pipelines has a first class citizen. However, in the examples the tasks seem to be executed as a single sequence:



node {
// Mark the code checkout 'stage'....
stage 'Checkout'

// Get some code from a GitHub repository
git url: 'git@github.com:elifesciences/elife-bot.git'

// Mark the code build 'stage'....
stage 'Build'
echo "Unit tests will run here"

stage "Production"
echo "Deploying to production environment"
}


For deployment into production system it's often useful to require manual approval; is there a way to insert a manual button to press inside a pipeline?



I have been looking for possible steps to accomplish this on the docs, to no avail.










share|improve this question






















  • I don't know Jenkins, but isn't there a way to split your build plan into several steps, and having some of these steps be run only on a "manual trigger"?
    – tiktak
    May 5 '16 at 16:06










  • Best partial solution so far: an input step in the pipeline which stops and asks the user for input (or to abort the build). However, the stage and the status indicator keeps flashing while I wanted a stable state (e.g. you get into it Friday afternoon and decide to deploy on Monday.)
    – giorgiosironi
    May 6 '16 at 12:19













up vote
14
down vote

favorite
3









up vote
14
down vote

favorite
3






3





Jenkins 2 has pipelines has a first class citizen. However, in the examples the tasks seem to be executed as a single sequence:



node {
// Mark the code checkout 'stage'....
stage 'Checkout'

// Get some code from a GitHub repository
git url: 'git@github.com:elifesciences/elife-bot.git'

// Mark the code build 'stage'....
stage 'Build'
echo "Unit tests will run here"

stage "Production"
echo "Deploying to production environment"
}


For deployment into production system it's often useful to require manual approval; is there a way to insert a manual button to press inside a pipeline?



I have been looking for possible steps to accomplish this on the docs, to no avail.










share|improve this question













Jenkins 2 has pipelines has a first class citizen. However, in the examples the tasks seem to be executed as a single sequence:



node {
// Mark the code checkout 'stage'....
stage 'Checkout'

// Get some code from a GitHub repository
git url: 'git@github.com:elifesciences/elife-bot.git'

// Mark the code build 'stage'....
stage 'Build'
echo "Unit tests will run here"

stage "Production"
echo "Deploying to production environment"
}


For deployment into production system it's often useful to require manual approval; is there a way to insert a manual button to press inside a pipeline?



I have been looking for possible steps to accomplish this on the docs, to no avail.







jenkins






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 5 '16 at 14:48









giorgiosironi

198138




198138












  • I don't know Jenkins, but isn't there a way to split your build plan into several steps, and having some of these steps be run only on a "manual trigger"?
    – tiktak
    May 5 '16 at 16:06










  • Best partial solution so far: an input step in the pipeline which stops and asks the user for input (or to abort the build). However, the stage and the status indicator keeps flashing while I wanted a stable state (e.g. you get into it Friday afternoon and decide to deploy on Monday.)
    – giorgiosironi
    May 6 '16 at 12:19


















  • I don't know Jenkins, but isn't there a way to split your build plan into several steps, and having some of these steps be run only on a "manual trigger"?
    – tiktak
    May 5 '16 at 16:06










  • Best partial solution so far: an input step in the pipeline which stops and asks the user for input (or to abort the build). However, the stage and the status indicator keeps flashing while I wanted a stable state (e.g. you get into it Friday afternoon and decide to deploy on Monday.)
    – giorgiosironi
    May 6 '16 at 12:19
















I don't know Jenkins, but isn't there a way to split your build plan into several steps, and having some of these steps be run only on a "manual trigger"?
– tiktak
May 5 '16 at 16:06




I don't know Jenkins, but isn't there a way to split your build plan into several steps, and having some of these steps be run only on a "manual trigger"?
– tiktak
May 5 '16 at 16:06












Best partial solution so far: an input step in the pipeline which stops and asks the user for input (or to abort the build). However, the stage and the status indicator keeps flashing while I wanted a stable state (e.g. you get into it Friday afternoon and decide to deploy on Monday.)
– giorgiosironi
May 6 '16 at 12:19




Best partial solution so far: an input step in the pipeline which stops and asks the user for input (or to abort the build). However, the stage and the status indicator keeps flashing while I wanted a stable state (e.g. you get into it Friday afternoon and decide to deploy on Monday.)
– giorgiosironi
May 6 '16 at 12:19










4 Answers
4






active

oldest

votes

















up vote
12
down vote













input is the option you are looking for. Here is the way I'm using it. It's important to have the step outside a node, otherwise jenkins will hold an agent waiting for the next step. Keep in mind the second node may not use the same workspace as the first.



node {
stage('build'){
echo "building"
}
}
stage('Deploy approval'){
input "Deploy to prod?"
}
node {
stage('deploy to prod'){
echo "deploying"
}
}





share|improve this answer





















  • Given multiple pipelines can get there, what happens to the older ones who do not get deployed to production? Is there a way to stop the older ones from remaining there (don't know if they will be flashing) in an incomplete state?
    – giorgiosironi
    Feb 17 '17 at 15:57






  • 1




    as far as i can tell it will flash forever until you click abort, which is pretty crappy. you could probably setup a timeout to prevent some of these from getting lost. After the timeout you would lose the ability to deploy it though. jenkins.io/doc/pipeline/steps/workflow-basic-steps/…
    – Steve Miskiewicz
    Feb 17 '17 at 17:56








  • 1




    I didn't understand that input could be configured to not hold up an agent. This makes input way more useful.
    – djhaskin987
    Dec 6 '17 at 18:30


















up vote
0
down vote













In the end I created separate test-project and prod-project pipelines, where at the end of test-project the code is merged into an approved branch.



Then, the prod-project pipeline can be set up not to trigger for every new commit so that it can be deployed on-demand.






share|improve this answer




























    up vote
    0
    down vote













    Additionally, You can also add auto-timeout like below



            stage('build') {
    steps {
    sh """
    # Some commands
    """
    script {
    timeout(time: 10, unit: 'MINUTES') {
    input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy')
    }
    }
    }
    }

    stage('deploy') {
    when {
    branch 'master'
    }
    steps {
    sh """
    # some commands
    """
    }
    }


    If you look it up you can also bind the jenkins input to credentials of users accessing Jenkins if you only wish to permit specific individuals to be capable of answering - it also is underpinned by the fact that your Git controls are sufficient too.






    share|improve this answer






























      up vote
      0
      down vote













      This is just a simple example but you can trigger it however you need.



      stage{
      script{
      input "Continue?"
      ...enter code here
      ...
      }
      }





      share|improve this answer





















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "3"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1073489%2fis-there-a-way-to-insert-a-manual-approval-in-jenkins-2-pipelines%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        12
        down vote













        input is the option you are looking for. Here is the way I'm using it. It's important to have the step outside a node, otherwise jenkins will hold an agent waiting for the next step. Keep in mind the second node may not use the same workspace as the first.



        node {
        stage('build'){
        echo "building"
        }
        }
        stage('Deploy approval'){
        input "Deploy to prod?"
        }
        node {
        stage('deploy to prod'){
        echo "deploying"
        }
        }





        share|improve this answer





















        • Given multiple pipelines can get there, what happens to the older ones who do not get deployed to production? Is there a way to stop the older ones from remaining there (don't know if they will be flashing) in an incomplete state?
          – giorgiosironi
          Feb 17 '17 at 15:57






        • 1




          as far as i can tell it will flash forever until you click abort, which is pretty crappy. you could probably setup a timeout to prevent some of these from getting lost. After the timeout you would lose the ability to deploy it though. jenkins.io/doc/pipeline/steps/workflow-basic-steps/…
          – Steve Miskiewicz
          Feb 17 '17 at 17:56








        • 1




          I didn't understand that input could be configured to not hold up an agent. This makes input way more useful.
          – djhaskin987
          Dec 6 '17 at 18:30















        up vote
        12
        down vote













        input is the option you are looking for. Here is the way I'm using it. It's important to have the step outside a node, otherwise jenkins will hold an agent waiting for the next step. Keep in mind the second node may not use the same workspace as the first.



        node {
        stage('build'){
        echo "building"
        }
        }
        stage('Deploy approval'){
        input "Deploy to prod?"
        }
        node {
        stage('deploy to prod'){
        echo "deploying"
        }
        }





        share|improve this answer





















        • Given multiple pipelines can get there, what happens to the older ones who do not get deployed to production? Is there a way to stop the older ones from remaining there (don't know if they will be flashing) in an incomplete state?
          – giorgiosironi
          Feb 17 '17 at 15:57






        • 1




          as far as i can tell it will flash forever until you click abort, which is pretty crappy. you could probably setup a timeout to prevent some of these from getting lost. After the timeout you would lose the ability to deploy it though. jenkins.io/doc/pipeline/steps/workflow-basic-steps/…
          – Steve Miskiewicz
          Feb 17 '17 at 17:56








        • 1




          I didn't understand that input could be configured to not hold up an agent. This makes input way more useful.
          – djhaskin987
          Dec 6 '17 at 18:30













        up vote
        12
        down vote










        up vote
        12
        down vote









        input is the option you are looking for. Here is the way I'm using it. It's important to have the step outside a node, otherwise jenkins will hold an agent waiting for the next step. Keep in mind the second node may not use the same workspace as the first.



        node {
        stage('build'){
        echo "building"
        }
        }
        stage('Deploy approval'){
        input "Deploy to prod?"
        }
        node {
        stage('deploy to prod'){
        echo "deploying"
        }
        }





        share|improve this answer












        input is the option you are looking for. Here is the way I'm using it. It's important to have the step outside a node, otherwise jenkins will hold an agent waiting for the next step. Keep in mind the second node may not use the same workspace as the first.



        node {
        stage('build'){
        echo "building"
        }
        }
        stage('Deploy approval'){
        input "Deploy to prod?"
        }
        node {
        stage('deploy to prod'){
        echo "deploying"
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 17 '17 at 14:38









        Steve Miskiewicz

        22125




        22125












        • Given multiple pipelines can get there, what happens to the older ones who do not get deployed to production? Is there a way to stop the older ones from remaining there (don't know if they will be flashing) in an incomplete state?
          – giorgiosironi
          Feb 17 '17 at 15:57






        • 1




          as far as i can tell it will flash forever until you click abort, which is pretty crappy. you could probably setup a timeout to prevent some of these from getting lost. After the timeout you would lose the ability to deploy it though. jenkins.io/doc/pipeline/steps/workflow-basic-steps/…
          – Steve Miskiewicz
          Feb 17 '17 at 17:56








        • 1




          I didn't understand that input could be configured to not hold up an agent. This makes input way more useful.
          – djhaskin987
          Dec 6 '17 at 18:30


















        • Given multiple pipelines can get there, what happens to the older ones who do not get deployed to production? Is there a way to stop the older ones from remaining there (don't know if they will be flashing) in an incomplete state?
          – giorgiosironi
          Feb 17 '17 at 15:57






        • 1




          as far as i can tell it will flash forever until you click abort, which is pretty crappy. you could probably setup a timeout to prevent some of these from getting lost. After the timeout you would lose the ability to deploy it though. jenkins.io/doc/pipeline/steps/workflow-basic-steps/…
          – Steve Miskiewicz
          Feb 17 '17 at 17:56








        • 1




          I didn't understand that input could be configured to not hold up an agent. This makes input way more useful.
          – djhaskin987
          Dec 6 '17 at 18:30
















        Given multiple pipelines can get there, what happens to the older ones who do not get deployed to production? Is there a way to stop the older ones from remaining there (don't know if they will be flashing) in an incomplete state?
        – giorgiosironi
        Feb 17 '17 at 15:57




        Given multiple pipelines can get there, what happens to the older ones who do not get deployed to production? Is there a way to stop the older ones from remaining there (don't know if they will be flashing) in an incomplete state?
        – giorgiosironi
        Feb 17 '17 at 15:57




        1




        1




        as far as i can tell it will flash forever until you click abort, which is pretty crappy. you could probably setup a timeout to prevent some of these from getting lost. After the timeout you would lose the ability to deploy it though. jenkins.io/doc/pipeline/steps/workflow-basic-steps/…
        – Steve Miskiewicz
        Feb 17 '17 at 17:56






        as far as i can tell it will flash forever until you click abort, which is pretty crappy. you could probably setup a timeout to prevent some of these from getting lost. After the timeout you would lose the ability to deploy it though. jenkins.io/doc/pipeline/steps/workflow-basic-steps/…
        – Steve Miskiewicz
        Feb 17 '17 at 17:56






        1




        1




        I didn't understand that input could be configured to not hold up an agent. This makes input way more useful.
        – djhaskin987
        Dec 6 '17 at 18:30




        I didn't understand that input could be configured to not hold up an agent. This makes input way more useful.
        – djhaskin987
        Dec 6 '17 at 18:30












        up vote
        0
        down vote













        In the end I created separate test-project and prod-project pipelines, where at the end of test-project the code is merged into an approved branch.



        Then, the prod-project pipeline can be set up not to trigger for every new commit so that it can be deployed on-demand.






        share|improve this answer

























          up vote
          0
          down vote













          In the end I created separate test-project and prod-project pipelines, where at the end of test-project the code is merged into an approved branch.



          Then, the prod-project pipeline can be set up not to trigger for every new commit so that it can be deployed on-demand.






          share|improve this answer























            up vote
            0
            down vote










            up vote
            0
            down vote









            In the end I created separate test-project and prod-project pipelines, where at the end of test-project the code is merged into an approved branch.



            Then, the prod-project pipeline can be set up not to trigger for every new commit so that it can be deployed on-demand.






            share|improve this answer












            In the end I created separate test-project and prod-project pipelines, where at the end of test-project the code is merged into an approved branch.



            Then, the prod-project pipeline can be set up not to trigger for every new commit so that it can be deployed on-demand.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 10 '17 at 17:18









            giorgiosironi

            198138




            198138






















                up vote
                0
                down vote













                Additionally, You can also add auto-timeout like below



                        stage('build') {
                steps {
                sh """
                # Some commands
                """
                script {
                timeout(time: 10, unit: 'MINUTES') {
                input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy')
                }
                }
                }
                }

                stage('deploy') {
                when {
                branch 'master'
                }
                steps {
                sh """
                # some commands
                """
                }
                }


                If you look it up you can also bind the jenkins input to credentials of users accessing Jenkins if you only wish to permit specific individuals to be capable of answering - it also is underpinned by the fact that your Git controls are sufficient too.






                share|improve this answer



























                  up vote
                  0
                  down vote













                  Additionally, You can also add auto-timeout like below



                          stage('build') {
                  steps {
                  sh """
                  # Some commands
                  """
                  script {
                  timeout(time: 10, unit: 'MINUTES') {
                  input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy')
                  }
                  }
                  }
                  }

                  stage('deploy') {
                  when {
                  branch 'master'
                  }
                  steps {
                  sh """
                  # some commands
                  """
                  }
                  }


                  If you look it up you can also bind the jenkins input to credentials of users accessing Jenkins if you only wish to permit specific individuals to be capable of answering - it also is underpinned by the fact that your Git controls are sufficient too.






                  share|improve this answer

























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    Additionally, You can also add auto-timeout like below



                            stage('build') {
                    steps {
                    sh """
                    # Some commands
                    """
                    script {
                    timeout(time: 10, unit: 'MINUTES') {
                    input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy')
                    }
                    }
                    }
                    }

                    stage('deploy') {
                    when {
                    branch 'master'
                    }
                    steps {
                    sh """
                    # some commands
                    """
                    }
                    }


                    If you look it up you can also bind the jenkins input to credentials of users accessing Jenkins if you only wish to permit specific individuals to be capable of answering - it also is underpinned by the fact that your Git controls are sufficient too.






                    share|improve this answer














                    Additionally, You can also add auto-timeout like below



                            stage('build') {
                    steps {
                    sh """
                    # Some commands
                    """
                    script {
                    timeout(time: 10, unit: 'MINUTES') {
                    input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy')
                    }
                    }
                    }
                    }

                    stage('deploy') {
                    when {
                    branch 'master'
                    }
                    steps {
                    sh """
                    # some commands
                    """
                    }
                    }


                    If you look it up you can also bind the jenkins input to credentials of users accessing Jenkins if you only wish to permit specific individuals to be capable of answering - it also is underpinned by the fact that your Git controls are sufficient too.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jul 19 at 9:49









                    Community

                    1




                    1










                    answered Jun 22 at 9:48









                    Kru

                    11




                    11






















                        up vote
                        0
                        down vote













                        This is just a simple example but you can trigger it however you need.



                        stage{
                        script{
                        input "Continue?"
                        ...enter code here
                        ...
                        }
                        }





                        share|improve this answer

























                          up vote
                          0
                          down vote













                          This is just a simple example but you can trigger it however you need.



                          stage{
                          script{
                          input "Continue?"
                          ...enter code here
                          ...
                          }
                          }





                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            This is just a simple example but you can trigger it however you need.



                            stage{
                            script{
                            input "Continue?"
                            ...enter code here
                            ...
                            }
                            }





                            share|improve this answer












                            This is just a simple example but you can trigger it however you need.



                            stage{
                            script{
                            input "Continue?"
                            ...enter code here
                            ...
                            }
                            }






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 22 at 14:30









                            Oren

                            1




                            1






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Super User!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1073489%2fis-there-a-way-to-insert-a-manual-approval-in-jenkins-2-pipelines%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Сан-Квентин

                                8-я гвардейская общевойсковая армия

                                Алькесар