-
Notifications
You must be signed in to change notification settings - Fork 830
JCasC
See Configuration as Code for an introduction to managing global Jenkins settings as code.
The Job DSL plugin provides an extension to run Job DSL scripts when configuring Jenkins using Configuration as Code. These scripts can be used to create an initial seed job.
To get started, add a root element called jobs
. The given script will be executed by the Job DSL plugin.
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 Job DSL scripts from a file or URL.
jobs:
- file: ./jobdsl/job.groovy
Note that relative paths are resolved relative to the current working directory of the Jenkins server,
which may not necessarily be the same as $JENKINS_HOME
, depending on how your server was started.
jobs:
- url: https://example.acme.org/job-dsl/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
You can pass values from the YAML file to the Job DSL script.
jobs:
- providedEnv:
SUPERHERO: 'Midnighter'
- file: ./jobdsl/job.groovy
//job.groovy
job('awesome-job') {
description("favorite job of ${SUPERHERO}")
}
Stack Overflow | Mailing List | API Reference | Issue Tracker | Playground | Plugin | Wiki | GitHub
Home
Release Notes
Migration
Talks and Blog Posts
Documentation
Tutorial
Dynamic DSL
Configure Blocks
Job DSL Commands
Script Security
Handling Credentials
Configuration as Code
FAQ
Real World Examples
User Power Moves
IDE Support
Testing DSL Scripts
For Developers
Extending the DSL
Job DSL Architecture