-
Notifications
You must be signed in to change notification settings - Fork 356
/
Copy pathBitbucketBuildStatus.java
286 lines (234 loc) · 6.89 KB
/
BitbucketBuildStatus.java
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
/*
* The MIT License
*
* Copyright (c) 2016, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.cloudbees.jenkins.plugins.bitbucket.api;
import com.fasterxml.jackson.annotation.JsonIgnore;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
public class BitbucketBuildStatus {
/**
* Enumeration of possible Bitbucket commit notification states
*/
public enum Status {
INPROGRESS("INPROGRESS"),
FAILED("FAILED"),
// available only in Cloud
STOPPED("STOPPED"),
// available only in Data Center
CANCELLED("CANCELLED"),
SUCCESSFUL("SUCCESSFUL");
private final String status;
Status(final String status) {
this.status = status;
}
@Override
public String toString() {
return status;
}
}
/**
* A summary of the passed, failed and skipped tests
*/
public static class TestResults {
private int successful;
private int failed;
private int skipped;
@Restricted(DoNotUse.class)
public TestResults() {
}
public TestResults(int successful, int failed, int skipped) {
this.successful = successful;
this.failed = failed;
this.skipped = skipped;
}
public int getSuccessful() {
return successful;
}
public void setSuccessful(int successful) {
this.successful = successful;
}
public int getFailed() {
return failed;
}
public void setFailed(int failed) {
this.failed = failed;
}
public int getSkipped() {
return skipped;
}
public void setSkipped(int skipped) {
this.skipped = skipped;
}
}
/**
* The commit hash to set the status on
*/
@JsonIgnore
private String hash;
/**
* Text shown in the UI
*/
private String description;
/**
* One of: INPROGRESS|FAILED|STOPPED|SUCCESSFUL
*/
private Status state;
/**
* The URL to link from the status details
*/
private String url;
/**
* Usually the job name in Jenkins
*/
private String key;
/**
* The parent key
*/
private String parent;
/**
* A short name, usually #job-name, #build-number (will be shown as link
* text in BB UI)
*/
private String name;
/**
* The fully qualified git reference e.g. refs/heads/master.
*/
private String refname;
/**
* Duration of a completed build in milliseconds.
*/
private long buildDuration;
/**
* A unique identifier of this particular run.
*/
private int buildNumber;
/**
* A summary of the test results.
*/
private TestResults testResults;
// Used for marshalling/unmarshalling
@Restricted(DoNotUse.class)
public BitbucketBuildStatus() {}
public BitbucketBuildStatus(String hash,
String description,
@NonNull Status state,
String url,
@NonNull String key,
String name,
@Nullable String refname) {
this.hash = hash;
this.description = description;
this.state = state;
this.url = url;
this.key = key;
this.name = name;
this.refname = refname;
}
/**
* Copy constructor.
*
* @param other from copy to.
*/
public BitbucketBuildStatus(@NonNull BitbucketBuildStatus other) {
this.hash = other.hash;
this.description = other.description;
this.state = other.state;
this.url = other.url;
this.key = other.key;
this.name = other.name;
this.refname = other.refname;
this.buildDuration = other.buildDuration;
this.parent = other.parent;
if(other.testResults != null) {
this.testResults = new TestResults(other.testResults.failed, other.testResults.successful, other.testResults.skipped);
}
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getState() {
return state.toString();
}
public void setState(Status state) {
this.state = state;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRefname() {
return refname;
}
public void setRefname(String refname) {
this.refname = refname;
}
public long getBuildDuration() {
return buildDuration;
}
public void setBuildDuration(long buildDuration) {
this.buildDuration = buildDuration;
}
public int getBuildNumber() {
return buildNumber;
}
public void setBuildNumber(int buildNumber) {
this.buildNumber = buildNumber;
}
public void setParent(String parent) {
this.parent = parent;
}
public String getParent() {
return parent;
}
public TestResults getTestResults() {
return testResults;
}
public void setTestResults(TestResults testResults) {
this.testResults = testResults;
}
}