Jenkins如何创建管道手动步骤 [英] Jenkins how to create pipeline manual step

查看:21
本文介绍了Jenkins如何创建管道手动步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Jenkins2 之前,我使用

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

效果很好,但我想使用从 groovy 脚本 (Jenkinsfile) 生成的新 Jenkins 管道来创建手动步骤.

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

到目前为止,我想出了 input jenkins 步骤.

So far I came up with input jenkins step.

使用 jenkinsfile 脚本:

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
}

但这会等待用户输入,注意构建尚未完成.我可以将超时添加到 input,但这不允许我选择/触发构建并在以后部署它:

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 获得与之前使用 Build Pipeline Plugin 相同/相似的手动步骤/触发器结果?

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

推荐答案

这是 Jenkins Pipeline 能力 IMO 的巨大差距.由于管道是一项单一的工作,因此绝对难以提供.一种解决方案可能是将工作空间归档"为工件"(tar 并将 **/* 归档为workspace.tar.gz"),然后让另一个管道复制工件并将其解压缩到新的工作空间中.这允许第二个管道从前一个停止的地方开始.当然,没有办法保证第二条管道不能不按顺序执行或多次执行.这太糟糕了.Delivery Pipeline Plugin 在这里真的很出色.您可以直接从视图中执行一个新管道 - 而不是第一个作业.无论如何 - 没有太多答案 - 但它是我要尝试的路径.

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.

这个插件看起来很有前途:

This plugin looks promising:

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

这篇关于Jenkins如何创建管道手动步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆