README: Add section about configuring with Job DSL. Fixes #722.

This commit is contained in:
Owen Mehegan 2018-04-04 16:45:48 +10:00
parent f95e65964b
commit a08fc040dd
1 changed files with 29 additions and 0 deletions

View File

@ -14,6 +14,7 @@
- [Job trigger configuration](#job-trigger-configuration)
- [Freestyle and Pipeline jobs](#freestyle-and-pipeline-jobs)
- [Pipeline Multibranch jobs](#pipeline-multibranch-jobs-1)
- [Multibranch Pipeline jobs with Job DSL](#multibranch-pipeline-jobs-with-job-dsl)
- [Build status configuration](#build-status-configuration)
- [Freestyle jobs](#freestyle-jobs-1)
- [Scripted Pipeline jobs](#scripted-pipeline-jobs)
@ -255,6 +256,34 @@ properties([
])
```
### Multibranch Pipeline jobs with Job DSL
You can use the [Dynamic DSL](https://github.com/jenkinsci/job-dsl-plugin/wiki/Dynamic-DSL) feature of Job DSL to configure the job trigger. See <https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java> for the methods you can use.
```groovy
job('seed-job') {
description('Job that makes sure a service has a build pipeline available')
parameters {
// stringParam('gitlabSourceRepoURL', '', 'the git repository url, e.g. git@git.your-domain.com:kubernetes/cronjobs/cleanup-jenkins.git')
}
triggers {
gitlab {
secretToken(System.getenv("API_TOKEN"))
triggerOnNoteRequest(false)
}
}
steps {
dsl {
text(new File('/usr/share/jenkins/ref/jobdsl/multibranch-pipeline.groovy').getText('UTF-8'))
}
}
}
```
## Build status configuration
You can optionally have your Jenkins jobs send their build status back to GitLab, where it will be displayed in the commit or merge request UI as appropriate.