Skip to content
Daniel Spilker edited this page Apr 26, 2019 · 6 revisions

Via configuratin-as-code-plugin also known as JCasC

It is possible to configure initial seed jobs through a yaml config file.
The basics for job dsl is you have a root element called jobs that will be parsed to configure via job dsl

Examples of config file

jobs:
  - script: >
      multibranchPipelineJob('configuration-as-code') {
          branchSources {
              git {
                  id = 'configuration-as-code'
                  remote('https://github.com/jenkinsci/configuration-as-code-plugin.git')
              }
          }
      }

You can also fetch your job dsl from a file or URL

jobs:
  - file: ./jobdsl/job.groovy
jobs:
  - url: https://raw.githubusercontent.com/jenkinsci/job-dsl-plugin/master/job-dsl-plugin/src/test/resources/javaposse/jobdsl/plugin/testjob.groovy

you can reference multiple scripts, files, and urls

jobs:
  - script: >
    job('testJob1') {
        scm {
            git('git://github.com/quidryan/aws-sdk-test.git')
        }
        triggers {
            scm('H/15 * * * *')
        }
        steps {
            maven('-e clean test')
        }
    }

  - script: >
    job('testJob2') {
        scm {
            git('git://github.com/quidryan/aws-sdk-test.git')
        }
        triggers {
            scm('H/15 * * * *')
        }
        steps {
            maven('-e clean test')
        }
    }

  - file: ./jobdsl/job1.groovy
  - file: ./jobdsl/job2.groovy