Jenkins how to create pipeline manual step

倾然丶 夕夏残阳落幕 提交于 2019-11-30 10:26:59

问题


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

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:

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


回答1:


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



来源:https://stackoverflow.com/questions/39913886/jenkins-how-to-create-pipeline-manual-step

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!