Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass env vars to a MultibranchPipelineJob created by Jenkins Job DSL?

I am creating a MultibranchPipelineJob with Jenkins Job DSL. I want to pass some environment variables to the job, but I can't figure out how to do that from the documentation.

like image 389
Assen Kolov Avatar asked Aug 15 '17 15:08

Assen Kolov


People also ask

How do you pass parameters in the Multibranch pipeline?

If you want to add new parameters you have to do it using properties in Jenkinsfile - goto <JENKINS URL>/pipeline-syntax and generate code for the properties step.

How does Jenkins environment variables work?

What are Environment Variables in Jenkins? Environment variables are global key-value pairs Jenkins can access and inject into a project. Use Jenkins environment variables to avoid having to code the same values for each project. Other benefits of using Jenkins environment variables include improved security.


1 Answers

MultibranchPipeline Job no longer support parameters

You can use Folder Properties Plugin to set your Env variables, which can be accessed by all the jobs within that folder. https://plugins.jenkins.io/folder-properties/

However, the MultiBranch pipeline job has a lot of performance issues so we moved away from multibranch pipeline jobs. We wrote a DSL job that would act as a multibranch pipeline job - which will scan through the git branches and create Simple pipeline jobs as needed.

like image 189
Dinesh Avatar answered Sep 21 '22 01:09

Dinesh