/
jenkins.go
48 lines (40 loc) · 1.03 KB
/
jenkins.go
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
46
47
48
package config
import (
"sort"
)
// Jenkins is the main Jenkins config, including credentials and the whitelisted jobs
type Jenkins struct {
Host string
Username string
Password string
Jobs JenkinsJobs
}
// IsEnabled checks if a host was defined...by default it's not set
func (c Jenkins) IsEnabled() bool {
return c.Host != ""
}
// JobConfig concrete job configuration -> only defined jobs are (re)startable
type JobConfig struct {
Parameters []JobParameter
Trigger string
OnStart []string
OnSuccess []string
OnFailure []string
}
// JobParameter are defined build parameters per job
type JobParameter struct {
Name string
Default string
Type string
}
// JenkinsJobs is the list of all (whitelisted) Jenkins jobs
type JenkinsJobs map[string]JobConfig
// GetSortedNames get all defined job names, sorted by name
func (j JenkinsJobs) GetSortedNames() []string {
jobNames := make([]string, 0, len(j))
for jobName := range j {
jobNames = append(jobNames, jobName)
}
sort.Strings(jobNames)
return jobNames
}