-
Notifications
You must be signed in to change notification settings - Fork 26
/
CloudBeesFlowSCM.java
149 lines (119 loc) · 3.45 KB
/
CloudBeesFlowSCM.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
package org.jenkinsci.plugins.electricflow.extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class CloudBeesFlowSCM implements ExtensionPoint {
private static final Log log = LogFactory.getLog(CloudBeesFlowSCM.class);
protected String scmReportUrl;
protected String scmType;
protected String commitId;
protected long timestamp;
protected String author;
protected String authorEmail;
protected String commitMessage;
// constructor
public CloudBeesFlowSCM() {}
public static CloudBeesFlowSCM build(Object obj) {
final Jenkins jenkins = Jenkins.get();
if (jenkins != null) {
ExtensionList.lookup(CloudBeesFlowSCM.class);
final ExtensionList<CloudBeesFlowSCM> makers = ExtensionList.lookup(CloudBeesFlowSCM.class);
for (CloudBeesFlowSCM m : makers) {
if (log.isDebugEnabled()) {
log.debug("CloudBeesFlowSCM:: Iterating through extensions");
}
boolean applicable = m.isApplicable(obj);
if (applicable) {
if (log.isDebugEnabled()) {
log.debug("CloudBeesFlowSCM:: Applicable");
}
m.populate(obj);
CloudBeesFlowSCM retval = m.generate();
return retval;
}
}
}
return null;
}
public JSONObject toJsonObject() {
JSONObject json = new JSONObject();
if (this.getTimestamp() > 0) {
json.put("timestamp", this.getTimestamp());
}
if (this.getScmReportUrl() != null) {
json.put("scmRepoUrl", this.getScmReportUrl());
}
if (this.getScmType() != null) {
json.put("scmType", this.getScmType());
}
if (this.getCommitId() != null) {
json.put("commitId", this.getCommitId());
}
if (this.getAuthor() != null) {
json.put("author", this.getAuthor());
}
if (this.getAuthorEmail() != null) {
json.put("authorEmail", this.getAuthorEmail());
}
if (this.getCommitMessage() != null) {
json.put("commitMessage", this.getCommitMessage());
}
return json;
}
// service methods
// isApplicable() returns false because it will be implemented in subclasses
public boolean isApplicable(Object object) {
return false;
}
// populate
public void populate(Object object) {}
public CloudBeesFlowSCM generate() {
return null;
}
/* getters and setters */
public String getScmReportUrl() {
return scmReportUrl;
}
public void setScmReportUrl(String scmReportUrl) {
this.scmReportUrl = scmReportUrl;
}
public String getScmType() {
return scmType;
}
public void setScmType(String scmType) {
this.scmType = scmType;
}
public String getCommitId() {
return commitId;
}
public void setCommitId(String commitId) {
this.commitId = commitId;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getAuthorEmail() {
return authorEmail;
}
public void setAuthorEmail(String authorEmail) {
this.authorEmail = authorEmail;
}
public String getCommitMessage() {
return commitMessage;
}
public void setCommitMessage(String commitMessage) {
this.commitMessage = commitMessage;
}
}