简体   繁体   中英

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. The variable is defined in the 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'

Is this possible via a 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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