65

Prior Jenkins2 I was using Build Pipeline Plugin to build and manually deploy application to server. Old configuration: jenkins-pipeline-plugin

That works great, but I want to use new Jenkins pipeline, generated from groovy script (Jenkinsfile), to create manual step.

So far I came up with input jenkins step.

Used jenkinsfile script:

node {
   stage 'Checkout'
   // Get some code from repository

   stage 'Build'
   // Run the build
}

stage 'deployment'
input 'Do you approve deployment?'
node {
    //deploy things
}

But this waits for user input, noting that build is not completed. I could add timeout to input, but this won't allow me to pick/trigger a build and deploy it later on:

jenkins-pipeline

How can I achive same/similiar result for manual step/trigger with new jenkins-pipeline as prior with Build Pipeline Plugin?

Zigac
  • 1,551
  • 1
  • 16
  • 27
  • 1
    I'm having the same issue. The pipeline works, but I'd very much prefer my build to be shown as successful and have a manual action to deploy/promote the build. – Thomas Jan 21 '17 at 15:55
  • This should be resolved with "checkpoint" plugin. But currently this is still not possible in OSS version but voting is going on at their issue tracker [JENKINS-33846](https://issues.jenkins-ci.org/browse/JENKINS-33846) – Zigac Apr 26 '17 at 18:08
  • 3
    I'm planning to migrate from Build Pipeline Plugin to Jenkins Pipelines but I'm at the same point as you. As I see your post is from 2016, is there a solution to this problem? Thanks – Gerard Ribas Sep 03 '18 at 14:48

2 Answers2

33

This is a huge gap in the Jenkins Pipeline capabilities IMO. Definitely hard to provide due to the fact that a pipeline is a single job. One solution might be to "archive" the workspace as an "artifact" (tar and archive **/* as 'workspace.tar.gz'), and then have another pipeline copy the artifact and and untar it into the new workspace. This allows the second pipeline to pickup where the previous one left off. Of course there is no way to gauentee that the second pipeline cannot be executed out of turn or more than once. Which is too bad. The Delivery Pipeline Plugin really shines here. You execute a new pipeline right from the view - instead of the first job. Anyway - not much of an answer - but its the path I'm going to try.

EDIT: This plugin looks promising:

https://github.com/jenkinsci/external-workspace-manager-plugin/blob/master/doc/PIPELINE_EXAMPLES.md

Michael Andrews
  • 828
  • 8
  • 13
  • 21
    That gap is so huge, one could call it "broken by design". We keep using the Delivery Pipeline Plugin for that reason. It's a bit complicated to setup the job chaining, but it does work well and allows fine grained permissions.We're investigating a switch to Gitlab CI though, their pipelines can do manual steps just fine. Not sure what's hindering Jenkins there. – T. Kuther Mar 23 '17 at 11:37
  • Well, that plugin looks really promising, so if i understand I can put in place upstream pipeline as separate auto job which will do the build and downstream pipeline which will share the workstpace with upstream and where I can implement the button and that should work then. – kensai Mar 24 '17 at 20:54
0

You only need to include your input under the steps section. Steps run in sequence, so you can gate them one by one. If you want to redeployenter image description here pipeline { agent any

stages {
    stage('Build') {
        steps {
            echo 'Building...'
        }
    }
    stage('Dev environment') {
        steps {
            input 'Do you approve deployment?'
            echo 'Hello Dev'
        }
    }
    stage('Beta environment') {
        steps {
            input 'Do you approve deployment?'
            echo 'Hello beta'
        }
    }
    stage('Production environment') {
        steps {
            input 'Do you approve deployment?'
            echo 'Hello Prod'
        }
    }
}

}

In the image below, build was completed, dev deployment was approved, and beta deployment was pending.

enter image description here

user1447414
  • 1,306
  • 2
  • 12
  • 25