简体   繁体   English

根据“视图”选项卡定义要在詹金斯管道中运行的阶段

[英]Define what Stages to run in a Jenkins Pipeline based on View Tab

I have a Jenkinsfile that lets me decide what GitHub branch to build on as a 'Build with Parameters' build step. 我有一个Jenkinsfile,可让我确定要在哪个GitHub分支上进行构建,这是“使用参数构建”构建步骤。 The variable is defined in the Jenkinsfile. 该变量在Jenkinsfile中定义。

What I need is a way to also decide what environment to build in ie Dev, Staging, PreProd, Prod, where environment is selected based on the 'view' the job is in. Only certain build Stages will run based on that 'view' 我需要的是一种还可以确定要构建哪种环境的方法,即Dev,Staging,PreProd,Prod,其中根据作业所在的“视图”选择环境。仅某些构建阶段将基于该“视图”运行

Is this possible via a Jenkinsfile? 是否可以通过Jenkinsfile?

Views can include projects, but from inside the project there's no concept of a view. 视图可以包括项目,但是在项目内部没有视图的概念。

A common approach is to add a parameter to your project that specifies the build target environment. 一种常见的方法是在您的项目中添加一个指定构建目标环境的参数。 With that, you might be able to recreate your views with something like the View Job Filters Plugin . 这样,您就可以使用诸如“ 查看作业过滤器插件”之类的内容来重新创建视图。

Filter by Job Parameterization 按作业参数过滤

Use Regular Expressions to include or exclude parameterized jobs based on their build parameters. 使用正则表达式可根据其构建参数包含或排除参数化的作业。 Match the parameter name, build value, or description. 匹配参数名称,构建值或描述。 Alternately, you may opt to depend on the default configured value. 或者,您可以选择依赖默认配置值。

For the name, value, and description - a blank indicates you do not care about that field - it behaves as if you had assigned it the regular expression ".*". 对于名称,值和说明-空白表示您不关心该字段-它的行为就像您已为其指定了正则表达式“。*”。

This filter works with String, Boolean, File, Choice, and Validating String parameter types. 该过滤器适用于String,Boolean,File,Choice和Validating String参数类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM