forked from yosida95/golang-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 3
/
job.go
318 lines (277 loc) · 11.7 KB
/
job.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
package gojenkins
import "encoding/xml"
type Artifact struct {
DisplayPath string `json:"displayPath"`
FileName string `json:"fileName"`
RelativePath string `json:"relativePath"`
}
type ScmAuthor struct {
FullName string `json:"fullName"`
AbsoluteUrl string `json:"absoluteUrl"`
}
type ScmChangeSetPath struct {
EditType string `json:"editType"`
File string `json:"File"`
}
type ChangeSetItem struct {
AffectedPaths []string `json:"affectedPaths"`
CommitId string `json:"commitId"`
Timestamp int `json:"timestamp"`
Author ScmAuthor `json:"author"`
Comment string `json:"comment"`
Date string `json:"date"`
Id string `json:"id"`
Message string `json:"msg"`
Paths []ScmChangeSetPath `json:"paths"`
}
type ScmChangeSet struct {
Kind string `json:"kind"`
Items []ChangeSetItem `json:"items"`
}
type Build struct {
Id string `json:"id"`
Number int `json:"number"`
Url string `json:"url"`
FullDisplayName string `json:"fullDisplayName"`
Description string `json:"description"`
Timestamp int `json:"timestamp"`
Duration int `json:"duration"`
EstimatedDuration int `json:"estimatedDuration"`
Building bool `json:"building"`
KeepLog bool `json:"keepLog"`
Result string `json:"result"`
Artifacts []Artifact `json:"artifacts"`
Actions []Action `json:"actions"`
ChangeSet ScmChangeSet `json:"changeSet"`
}
type UpstreamCause struct {
ShortDescription string `json:"shortDescription"`
UpstreamBuild int `json:"upstreamBuild"`
UpstreamProject string `json:"upstreamProject"`
UpstreamUrl string `json:"upstreamUrl"`
}
type Job struct {
Actions []Action `json:"actions"`
Name string `json:"name"`
Url string `json:"url"`
Color string `json:"color"`
Buildable bool `json:"buildable"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
HealthReport []Health `json:"healthReport"`
LastCompletedBuild Build `json:"lastCompletedBuild"`
LastFailedBuild Build `json:"lastFailedBuild"`
LastStableBuild Build `json:"lastStableBuild"`
LastSuccessfulBuild Build `json:"lastSuccessfulBuild"`
LastUnstableBuild Build `json:"lastUnstableBuild"`
LastUnsuccessfulBuild Build `json:"lastUnsuccessfulBuild"`
}
type Health struct {
Description string `json:"description"`
}
type FreeJobItem struct {
Plugin string `xml:"plugin,attr"`
Actions string `xml:"actions"`
Description string `xml:"description"`
KeepDependencies string `xml:"keepDependencies"`
Properties JobProperties `xml:"properties"`
Scm Scm `xml:"scm"`
CanRoam string `xml:"canRoam"`
Disabled string `xml:"disabled"`
BlockBuildWhenDownstreamBuilding string `xml:"blockBuildWhenDownstreamBuilding"`
BlockBuildWhenUpstreamBuilding string `xml:"blockBuildWhenUpstreamBuilding"`
Triggers Triggers `xml:"triggers"`
ConcurrentBuild string `xml:"concurrentBuild"`
Goals string `xml:"goals"`
AggregatorStyleBuild string `xml:"aggregatorStyleBuild"`
IncrementalBuild string `xml:"incrementalBuild"`
IgnoreUpstremChanges string `xml:"ignoreUpstremChanges"`
ArchivingDisabled string `xml:"archivingDisabled"`
SiteArchivingDisabled string `xml:"siteArchivingDisabled"`
FingerprintingDisabled string `xml:"fingerprintingDisabled"`
ResolveDependencies string `xml:"resolveDependencies"`
ProcessPlugins string `xml:"processPlugins"`
MavenName string `xml:"mavenName"`
MavenValidationLevel string `xml:"mavenValidationLevel"`
DefaultGoals string `xml:"defaultGoals"`
RunHeadless string `xml:"runHeadless"`
DisableTriggerDownstreamProjects string `xml:"disableTriggerDownstreamProjects"`
Settings JobSettings `xml:"settings"`
GlobalSettings JobSettings `xml:"globalSettings"`
RunPostStepsIfResult RunPostStepsIfResult `xml:"runPostStepsIfResult"`
Postbuilders PostBuilders `xml:"postbuilders"`
}
type MavenJobItem struct {
XMLName struct{} `xml:"maven2-moduleset"`
Plugin string `xml:"plugin,attr"`
Actions string `xml:"actions"`
Description string `xml:"description"`
KeepDependencies string `xml:"keepDependencies"`
Properties JobProperties `xml:"properties"`
Scm Scm `xml:"scm"`
CanRoam string `xml:"canRoam"`
Disabled string `xml:"disabled"`
BlockBuildWhenDownstreamBuilding string `xml:"blockBuildWhenDownstreamBuilding"`
BlockBuildWhenUpstreamBuilding string `xml:"blockBuildWhenUpstreamBuilding"`
Triggers Triggers `xml:"triggers"`
ConcurrentBuild string `xml:"concurrentBuild"`
Goals string `xml:"goals"`
RootPOM string `xml:"rootPOM"`
AggregatorStyleBuild string `xml:"aggregatorStyleBuild"`
IncrementalBuild string `xml:"incrementalBuild"`
IgnoreUpstremChanges string `xml:"ignoreUpstremChanges"`
ArchivingDisabled string `xml:"archivingDisabled"`
SiteArchivingDisabled string `xml:"siteArchivingDisabled"`
FingerprintingDisabled string `xml:"fingerprintingDisabled"`
ResolveDependencies string `xml:"resolveDependencies"`
ProcessPlugins string `xml:"processPlugins"`
MavenName string `xml:"mavenName"`
MavenValidationLevel string `xml:"mavenValidationLevel"`
DefaultGoals string `xml:"defaultGoals"`
RunHeadless string `xml:"runHeadless"`
DisableTriggerDownstreamProjects string `xml:"disableTriggerDownstreamProjects"`
Settings JobSettings `xml:"settings"`
GlobalSettings JobSettings `xml:"globalSettings"`
RunPostStepsIfResult RunPostStepsIfResult `xml:"runPostStepsIfResult"`
Postbuilders PostBuilders `xml:"postbuilders"`
}
type GitUserRemoteConfig struct {
Url string `xml:"url"`
CredentialsId string `xml:"credentialsId"`
}
type Scm struct {
ConfigVersion string `xml:"configVersion"`
SubmoduleCfg struct {
Class string `xml:"class,attr"`
} `xml:"submoduleCfg"`
DoGenerateSubmoduleConfigurations string `xml:"doGenerateSubmoduleConfigurations"`
UserRemoteConfigs struct {
GitUserRemoteConfig GitUserRemoteConfig `xml:"hudson.plugins.git.UserRemoteConfig"`
} `xml:"userRemoteConfigs"`
Branches struct {
BranchSpec struct {
Name string `xml:"name"`
} `xml:"hudson.plugins.git.BranchSpec"`
} `xml:"branches"`
Class string `xml:"class,attr"`
Plugin string `xml:"plugin,attr"`
}
type ScmContent interface{}
type ScmSvn struct {
Locations Locations `xml:"locations"`
ExcludedRegions string `xml:"excludedRegions"`
IncludedRegions string `xml:"includedRegions"`
ExcludedUsers string `xml:"excludedUsers"`
ExcludedRevprop string `xml:"excludedRevprop"`
ExcludedCommitMessages string `xml:"excludedCommitMessages"`
WorkspaceUpdater WorkspaceUpdater `xml:"workspaceUpdater"`
IgnoreDirPropChanges string `xml:"ignoreDirPropChanges"`
FilterChangelog string `xml:"filterChangelog"`
}
type WorkspaceUpdater struct {
Class string `xml:"class,attr"`
}
type Locations struct {
Location []ScmSvnLocation `xml:"hudson.scm.SubversionSCM_-ModuleLocation"`
}
type ScmSvnLocation struct {
Remote string `xml:"remote"`
Local string `xml:"local"`
DepthOption string `xml:"depthOption"`
IgnoreExternalsOption string `xml:"ignoreExternalsOption"`
}
type PostBuilders struct {
XMLName xml.Name `xml:"postbuilders"`
PostBuilder []PostBuilder
}
type PostBuilder interface {
}
type ShellBuilder struct {
XMLName xml.Name `xml:"hudson.tasks.Shell"`
Command string `xml:"command"`
}
type JobSettings struct {
Class string `xml:"class,attr"`
JobSetting []JobSetting
}
type JobSetting struct {
}
type JobProperties interface {
}
type Triggers struct {
Trigger []Trigger
}
type Trigger interface {
}
type ScmTrigger struct {
XMLName struct{} `xml:"hudson.triggers.SCMTrigger"`
Spec string `xml:"spec"`
IgnorePostCommitHooks string `xml:"ignorePostCommitHooks"`
}
type RunPostStepsIfResult struct {
Name string `xml:"name"`
Ordinal string `xml:"ordinal"`
Color string `xml:"color"`
CompleteBuild string `xml:"completeBuild"`
}
type ScmGit struct {
UserRemoteConfigs UserRemoteConfigs `xml:"userRemoteConfigs"`
Branches Branches `xml:"branches"`
DoGenerateSubmoduleConfigurations bool `xml:"doGenerateSubmoduleConfigurations"`
GitBrowser GitBrowser `xml:"browser"`
GitSubmoduleCfg GitSubmoduleCfg `xml:"submoduleCfg"`
GitExtensions GitExtensions `xml:"extensions"`
}
type UserRemoteConfigs struct {
UserRemoteConfig UserRemoteConfig `xml:"hudson.plugins.git.UserRemoteConfig"`
}
type UserRemoteConfig struct {
Urls []string `xml:"url"`
}
type Branches struct {
BranchesSpec []BranchesSpec `xml:"hudson.plugins.git.BranchSpec"`
}
type BranchesSpec struct {
Name string `xml:"name"`
}
type GitBrowser struct {
Class string `xml:"class,attr"`
Url string `xml:"url"`
ProjectName string `xml:"projectName"`
}
type GitSubmoduleCfg struct {
Class string `xml:"class,attr"`
}
type GitExtensions struct {
Class string `xml:"class,attr"`
LocalBranch LocalBranch `xml:"hudson.plugins.git.extensions.impl.LocalBranch"`
}
type LocalBranch struct {
LocalBranch string `xml:"localBranch"`
}
//UnmarshalXML implements xml.UnmarshalXML intrface
//Decode between multiple types of Scm. for now only SVN is supported
//func (iscm *Scm) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// for _, v := range start.Attr {
// if v.Name.Local == "class" {
// iscm.Class = v.Value
// } else if v.Name.Local == "plugin" {
// iscm.Plugin = v.Value
// }
// }
// switch iscm.Class {
// case "hudson.scm.SubversionSCM":
// iscm.ScmContent = &ScmSvn{}
// err := d.DecodeElement(&iscm.ScmContent, &start)
// if err != nil {
// return err
// }
// case "hudson.plugins.git.GitSCM":
// iscm.ScmContent = &ScmGit{}
// err := d.DecodeElement(&iscm.ScmContent, &start)
// if err != nil {
// return err
// }
// }
// return nil
//}