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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With