EDIT (Oct 2016): Please see my other answer "Use milestone and lock" below, which includes recently introduced features.
Use timeout
Step
As first option, you can wrap your sh
step into a timeout
step.
node() {
stage 'Build to Stage' {
sh '# ...'
}
stage 'Promotion' {
timeout(time: 1, unit: 'HOURS') {
input 'Deploy to Production?'
}
}
stage 'Deploy to Production' {
sh '# ...'
}
}
This stops the build after the timeout.
Move input
Step to Flyweight Executor
Another option is to not allocate a heavyweight executor for the input
step. You can do this by using the input
step outside of the node
block, like this:
stage 'Build to Stage' {
node {
sh "echo building"
stash 'complete-workspace'
}
}
stage 'Promotion' {
input 'Deploy to Production?'
}
stage 'Deploy to Production' {
node {
unstash 'complete-workspace'
sh "echo deploying"
}
}
This is was probably the more elegant way, but can still be combined with the timeout
step.
EDIT: As pointed out by @amuniz, you have to stash/unstash the contents of the workspace, as different nodes respectively workspace directories might be allocated for the two node
steps.