forked from pviniciusfm/job-dsl-gradle-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example2Jobs.groovy
38 lines (31 loc) · 953 Bytes
/
example2Jobs.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import groovy.json.JsonSlurper
String basePath = 'example2'
String repo = 'sheehan/grails-example'
folder(basePath) {
description 'This example shows how to create a set of jobs for each github branch, each in its own folder.'
}
URL branchUrl = "https://api.github.com/repos/$repo/branches".toURL()
List branches = new JsonSlurper().parse(branchUrl.newReader())
branches.each { branch ->
String safeBranchName = branch.name.replaceAll('/', '-')
folder "$basePath/$safeBranchName"
job("$basePath/$safeBranchName/grails-example-build") {
scm {
github repo, branch.name
}
triggers {
scm 'H/30 * * * *'
}
steps {
grails 'test-app war', true
}
}
job("$basePath/$safeBranchName/grails-example-deploy") {
parameters {
stringParam 'host'
}
steps {
shell 'scp war file; restart...'
}
}
}