詹金斯:如何跳过多分支管道中的特定阶段? [英] Jenkins: How to skip a specific stage in a multibranch pipeline?
问题描述
我们所有分支机构都有阶段(构建)".临时如何跳过此阶段,使其在多分支管道中的所有分支上运行.我知道一种解决方案是在舞台上使用条件时使用,并要求所有开发人员将该分支拉入他们的分支.但是,这需要大量的工作和协调.取而代之的是,我正在寻找一个全局配置,我们可以在任何分支上简单地按名称跳过该阶段.
We have "stage (build)" on all our branches. Temporarily how can we skip this stage to run on all our branches in multibranch pipeline. I know one solution is use when condition on stage and ask all developers to pull that branch into their branch. But thats lot of work and coordination. Instead I am looking for a global configuration where we can simply skip the stage by name on any branch.
推荐答案
听起来像您将Jenkinsfile放在代码的旁边,但是想要从管理的角度更改Jenkinsfile的运行方式.
It sounds like you keep the Jenkinsfile alongside the code, but want to change how the Jenkinsfile runs from an administrative point of view.
您可以将此阶段存储在单独的(版本控制偏好的版本)存储库中.在执行阶段之前,先加载存储库,然后加载脚本文件,然后在阶段内执行该文件中定义的方法.
You could store this stage in a separate (version control flavor of preference) repository. Before you execute the stage, load in the repository then load in the script file and within the stage execute a method defined in that file.
或者,在构建作业中添加一个参数(假定您不是通过Jenkinsfile中的选项来设置参数),该参数是布尔值,可以使用或跳过该阶段,并且可以在想要将其打开时修改项目配置开启或关闭
Alternatively, add a parameter to the build job (this assumes you aren't setting parameters via options in the Jenkinsfile) that is a boolean to use or skip the stage and you can modify the project configuration when you want to turn it on or off
这篇关于詹金斯:如何跳过多分支管道中的特定阶段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!