Permalink
c85bca6 Aug 24, 2018
3 contributors

Users who have contributed to this file

@ooxi @ndeloof @yogeek
34 lines (26 sloc) 1.41 KB

How to create initial "seed" job

Configuration is not just about setting up jenkins master, it's also about creating an initial set of jobs. For this purpose, we delegate to the popular job-dsl-plugin and run a job-dsl script to create an initial set of jobs.

Be aware that you also need configuration-as-code-support besides configuration-as-code plugin already installed, otherwise the jobs root element cannot be parsed.

Typical usage is to rely on a multi-branch, or organization folder job type, so further jobs will be dynamically created. So a multi-branch seed job will prepare a master to be fully configured for CI/CD targeting a repository or organization.

Job-DSL plugin uses groovy syntax for it's job configuration DSL, so you'll have to mix yaml and groovy within your configuration-as-code file:

jenkins:
  systemMessage: "Simple seed job example"
jobs:
  - script: >
      multibranchPipelineJob('configuration-as-code') {
          branchSources {
              git {
                  id = 'configuration-as-code'
                  remote('https://github.com/jenkinsci/configuration-as-code-plugin.git')
              }
          }
      }

Examples

Please refer to demos for examples to configure more complex jobs.