Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-59037

Environment from CasC yaml to job dsl script

XMLWordPrintable

    • job-dsl 1.76

      When executing job dsl scripts from configuration-as-code, there should be a way to pass values from the yaml files into the job dsl groovy.

      This would be useful in cases where one wishes to generate the same jobs from CasC on multiple masters, with minor variations.

      Example:

      common_jobs.groovy
      job('awesome-job') {
      	description("favorite job of ${SUPERHERO}")
      }
      
      master_one.yml
      jobs:
        - providedEnv:
            SUPERHERO: 'Wonder Woman'
        - file: common_jobs.groovy
      
      master_two.yml
      jobs: 
        - providedEnv:
            SUPERHERO: 'Midnighter'
        - file: common_jobs.groovy
      

      Alternatively, one could set an environment variable on the host VM/container of Jenkins. Depending on the setup, that can be inconvenient to do. Also, that variable would unnecessarily pollute the environment of every job etc.

            daspilker Daniel Spilker
            rudolfwg Rudolf-Walter Kiss-Szakacs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: