forked from sheehan/job-dsl-gradle-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJobScriptsSpec.groovy
46 lines (38 loc) · 1.07 KB
/
JobScriptsSpec.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
39
40
41
42
43
44
45
package com.dslexample
import groovy.io.FileType
import javaposse.jobdsl.dsl.DslScriptLoader
import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.plugin.JenkinsJobManagement
import org.junit.ClassRule
import org.jvnet.hudson.test.JenkinsRule
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
/**
* Tests that all dsl scripts in the jobs directory will compile.
*/
class JobScriptsSpec extends Specification {
@Shared
@ClassRule
JenkinsRule jenkinsRule = new JenkinsRule()
@Unroll
void 'test script #file.name'(File file) {
given:
JobManagement jm = new JenkinsJobManagement(System.out, [:], new File('.'))
when:
new DslScriptLoader(jm).runScript(file.text)
then:
noExceptionThrown()
where:
file << jobFiles
}
static List<File> getJobFiles() {
List<File> files = []
new File('jobs').eachFileRecurse(FileType.FILES) {
if (it.name.endsWith('.groovy')) {
files << it
}
}
files
}
}