-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
346 lines (318 loc) · 12.6 KB
/
model.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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
package jenkins
import "encoding/xml"
const (
GitScmClass = "hudson.plugins.git.GitSCM"
GitScmPlugin = "git@3.3.1"
ScmConfigVersion = 2
WorkflowJobPlugin = "workflow-job@2.17"
FlowDefinitionClass = "org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition"
FlowDefinitionPlugin = "workflow-cps@2.43"
JenkinsJobPrefix = "Rancher_Pipeline_"
)
var JenkinsDefaultUser = "admin"
var JenkinsDefaultToken = "admin"
type PipelineJob struct {
XMLName xml.Name `xml:"flow-definition"`
Plugin string `xml:"plugin,attr"`
Definition Definition `xml:"definition"`
}
type Definition struct {
Class string `xml:"class,attr"`
Plugin string `xml:"plugin,attr"`
Script string `xml:"script"`
Sandbox bool `xml:"sandbox"`
}
type Project struct {
XMLName xml.Name `xml:"project"`
Actions string `xml:"actions"`
Description string `xml:"description"`
KeepDependencies bool `xml:"keepDependencies"`
Properties string
Scm Scm `xml:"scm"`
AssignedNode string `xml:"assignedNode"`
CanRoam bool `xml:"canRoam"`
Disabled bool `xml:"disabled"`
BlockBuildWhenDownstreamBuilding bool `xml:"blockBuildWhenDownstreamBuilding"`
BlockBuildWhenUpstreamBuilding bool `xml:"blockBuildWhenUpstreamBuilding"`
Triggers Trigger `xml:"triggers"`
ConcurrentBuild bool `xml:"concurrentBuild"`
CustomWorkspace string `xml:"customWorkspace"`
Builders Builder `xml:"builders,omitempty"`
Publishers PostBuildTask `xml:"publishers>org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder"`
TimeStampWrapper TimestampWrapperPlugin `xml:"buildWrappers>hudson.plugins.timestamper.TimestamperBuildWrapper"`
TimeoutWrapper *TimeoutWrapperPlugin `xml:"buildWrappers>hudson.plugins.build__timeout.BuildTimeoutWrapper"`
PreSCMBuildStepsWrapper PreSCMBuildStepsWrapper `xml:"buildWrappers>org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper"`
}
type Scm struct {
Class string `xml:"class,attr"`
Plugin string `xml:"plugin,attr"`
ConfigVersion int `xml:"configVersion"`
GitRepo string `xml:"userRemoteConfigs>hudson.plugins.git.UserRemoteConfig>url"`
GitCredentialID string `xml:"userRemoteConfigs>hudson.plugins.git.UserRemoteConfig>credentialsId"`
GitBranch string `xml:"branches>hudson.plugins.git.BranchSpec>name"`
DoGenerateSubmoduleConfigurations bool `xml:"doGenerateSubmoduleConfigurations"`
SubmodelCfg string `xml:"submoduleCfg,omitempty"`
Extensions string `xml:"extensions"`
}
type Trigger struct {
BuildTrigger *BuildTrigger `xml:"jenkins.triggers.ReverseBuildTrigger,omitempty"`
FanInReverseBuildTrigger *BuildTrigger `xml:"org.lonkar.jobfanin.FanInReverseBuildTrigger,omitempty"`
}
type BuildTrigger struct {
Spec string `xml:"spec"`
Plugin string `xml:"plugin,attr"`
UpstreamProjects string `xml:"upstreamProjects"`
UpsteamProjects string `xml:"upsteamProjects"`
WatchUpstreamRecursively bool `xml:"watchUpstreamRecursively"`
ThresholdName string `xml:"threshold>name"`
ThresholdOrdinal int `xml:"threshold>ordinal"`
ThresholdColor string `xml:"threshold>color"`
ThresholdCompleteBuild bool `xml:"threshold>completeBuild"`
}
type TimestampWrapperPlugin struct {
Plugin string `xml:"plugin,attr"`
}
type TimeoutWrapperPlugin struct {
Plugin string `xml:"plugin,attr"`
Strategy TimeoutStrategy `xml:"strategy"`
Operation string `xml:"operationList>hudson.plugins.build__timeout.operations.FailOperation"`
}
type TimeoutStrategy struct {
Class string `xml:"class,attr"`
TimeoutMinutes int `xml:"timeoutMinutes"`
}
type PreSCMBuildStepsWrapper struct {
Plugin string `xml:"plugin,attr"`
FailOnError bool `xml:"failOnError"`
Command string `xml:"buildSteps>hudson.tasks.Shell>command"`
}
type PostBuildTask struct {
Plugin string `xml:"plugin,attr"`
GroovyScript GroovyScript `xml:"script"`
Behavior int `xml:"behavior"`
RunForMatrixParent bool `xml:"runForMatrixParent"`
}
type GroovyScript struct {
Plugin string `xml:"plugin,attr"`
Script string `xml:"script"`
Sandbox bool `xml:"sandbox"`
}
type Builder struct {
TaskShells []TaskShell `xml:"hudson.tasks.Shell"`
}
type TaskShell struct {
Command string `xml:"command"`
}
type Build struct {
ID string `json:"id,omitempty"`
KeepLog bool `json:"keepLog,omitempty"`
Number int `json:"number,omitempty"`
QueueID int `json:"queueId,omitempty"`
Result string `json:"result,omitempty"`
TimeStamp int64 `json:"timestamp,omitempty"`
BuiltOn string `json:"builtOn,omitempty"`
ChangeSet ChangeSet `json:"chanSet,omitempty"`
Duration int `json:"duration,omitempty"`
EstimatedDuration int `json:"estimatedDuration,omitempty"`
Building bool `json:"building,omitempty"`
}
type ChangeSet struct {
Kind string
Items []interface{}
}
type JobInfo struct {
Class string `json:"_class"`
Actions []struct {
Class string `json:"_class"`
} `json:"actions"`
Buildable bool `json:"buildable"`
Builds []struct {
Class string `json:"_class"`
Number int64 `json:"number"`
URL string `json:"url"`
} `json:"builds"`
Color string `json:"color"`
ConcurrentBuild bool `json:"concurrentBuild"`
Description string `json:"description"`
DisplayName string `json:"displayName"`
DisplayNameOrNull interface{} `json:"displayNameOrNull"`
DownstreamProjects []struct {
Class string `json:"_class"`
Color string `json:"color"`
Name string `json:"name"`
URL string `json:"url"`
} `json:"downstreamProjects"`
FirstBuild struct {
Class string `json:"_class"`
Number int64 `json:"number"`
URL string `json:"url"`
} `json:"firstBuild"`
FullDisplayName string `json:"fullDisplayName"`
FullName string `json:"fullName"`
HealthReport []struct {
Description string `json:"description"`
IconClassName string `json:"iconClassName"`
IconURL string `json:"iconUrl"`
Score int64 `json:"score"`
} `json:"healthReport"`
InQueue bool `json:"inQueue"`
KeepDependencies bool `json:"keepDependencies"`
LastBuild struct {
Class string `json:"_class"`
Number int64 `json:"number"`
URL string `json:"url"`
} `json:"lastBuild"`
LastCompletedBuild struct {
Class string `json:"_class"`
Number int64 `json:"number"`
URL string `json:"url"`
} `json:"lastCompletedBuild"`
LastFailedBuild struct {
Class string `json:"_class"`
Number int64 `json:"number"`
URL string `json:"url"`
} `json:"lastFailedBuild"`
LastStableBuild interface{} `json:"lastStableBuild"`
LastSuccessfulBuild interface{} `json:"lastSuccessfulBuild"`
LastUnstableBuild interface{} `json:"lastUnstableBuild"`
LastUnsuccessfulBuild struct {
Class string `json:"_class"`
Number int64 `json:"number"`
URL string `json:"url"`
} `json:"lastUnsuccessfulBuild"`
Name string `json:"name"`
NextBuildNumber int64 `json:"nextBuildNumber"`
Property []interface{} `json:"property"`
QueueItem interface{} `json:"queueItem"`
Scm struct {
Class string `json:"_class"`
} `json:"scm"`
UpstreamProjects []interface{} `json:"upstreamProjects"`
URL string `json:"url"`
}
type BuildInfo struct {
Class string `json:"_class"`
Actions []struct {
Class string `json:"_class"`
BuildsByBranchName struct {
OriginMaster struct {
Class string `json:"_class"`
BuildNumber int64 `json:"buildNumber"`
BuildResult interface{} `json:"buildResult"`
Marked struct {
SHA1 string `json:"SHA1"`
Branch []struct {
SHA1 string `json:"SHA1"`
Name string `json:"name"`
} `json:"branch"`
} `json:"marked"`
Revision struct {
SHA1 string `json:"SHA1"`
Branch []struct {
SHA1 string `json:"SHA1"`
Name string `json:"name"`
} `json:"branch"`
} `json:"revision"`
} `json:"origin/master"`
} `json:"buildsByBranchName"`
Causes []struct {
Class string `json:"_class"`
ShortDescription string `json:"shortDescription"`
UserID string `json:"userId"`
UserName string `json:"userName"`
} `json:"causes"`
LastBuiltRevision struct {
SHA1 string `json:"SHA1"`
Branch []struct {
SHA1 string `json:"SHA1"`
Name string `json:"name"`
} `json:"branch"`
} `json:"lastBuiltRevision"`
RemoteUrls []string `json:"remoteUrls"`
ScmName string `json:"scmName"`
} `json:"actions"`
Artifacts []interface{} `json:"artifacts"`
Building bool `json:"building"`
BuiltOn string `json:"builtOn"`
ChangeSet struct {
Class string `json:"_class"`
Items []interface{} `json:"items"`
Kind string `json:"kind"`
} `json:"changeSet"`
Description interface{} `json:"description"`
DisplayName string `json:"displayName"`
Duration int64 `json:"duration"`
EstimatedDuration int64 `json:"estimatedDuration"`
Executor interface{} `json:"executor"`
FullDisplayName string `json:"fullDisplayName"`
ID string `json:"id"`
KeepLog bool `json:"keepLog"`
Number int64 `json:"number"`
QueueID int64 `json:"queueId"`
Result string `json:"result"`
Timestamp int64 `json:"timestamp"`
URL string `json:"url"`
}
type Credential struct {
Scope string `json:"scope"`
ID string `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
Description string `json:"description"`
Class string `json:"$class"`
}
type WFBuildInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
StartTimeMillis int64 `json:"startTimeMillis"`
EndTimeMillis int64 `json:"endTimeMillis"`
DurationMillis int64 `json:"durationMillis"`
QueueDurationMillis int64 `json:"queueDurationMillis"`
PauseDurationMillis int64 `json:"pauseDurationMillis"`
Stages []Stage `json:"stages"`
}
type Stage struct {
ID string `json:"id"`
Name string `json:"name"`
ExecNode string `json:"execNode"`
Status string `json:"status"`
StartTimeMillis int64 `json:"startTimeMillis"`
EndTimeMillis int64 `json:"endTimeMillis"`
DurationMillis int64 `json:"durationMillis"`
Error NodeError `json:"error"`
}
type WFNodeInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
StartTimeMillis int64 `json:"startTimeMillis"`
EndTimeMillis int64 `json:"endTimeMillis"`
DurationMillis int64 `json:"durationMillis"`
ParseDurationMillis int64 `json:"parseDurationMillis"`
PauseDurationMillis int64 `json:"pauseDurationMillis"`
StageFlowNodes []Stage `json:"stageFlowNodes"`
}
type WFNodeLog struct {
NodeID string `json:"nodeId"`
NodeStatus string `json:"nodeStatus"`
Length int `json:"length"`
HasMore bool `json:"hasMore"`
Text string `json:"text"`
ConsoleURL string `json:"consoleUrl"`
}
type FlowNode struct {
ID string `json:"id"`
Name string `json:"name"`
ExecNode string `json:"execNode"`
Status string `json:"status"`
ParameterDescription string `json:"parameterDescription"`
StartTimeMillis int64 `json:"startTimeMillis"`
DurationMillis int64 `json:"durationMillis"`
PauseDurationMillis int64 `json:"pauseDurationMillis"`
Error NodeError `json:"error"`
}
type NodeError struct {
Type string `json:"type"`
Message string `json:"message"`
}