forked from jenkinsci/jira-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJiraVersionCreator.java
More file actions
119 lines (96 loc) · 3.33 KB
/
JiraVersionCreator.java
File metadata and controls
119 lines (96 loc) · 3.33 KB
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
package hudson.plugins.jira;
import hudson.Extension;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest2;
/**
* A build step which creates new Jira version
*
* @author Artem Koshelev artkoshelev@gmail.com
* @deprecated Replaced by {@link JiraVersionCreatorBuilder}. Read its
* description to see why. Kept for backward compatibility.
*/
@Deprecated
public class JiraVersionCreator extends Notifier {
private String jiraVersion;
private String jiraProjectKey;
private Boolean failIfAlreadyExists = true;
@DataBoundConstructor
public JiraVersionCreator(String jiraVersion, String jiraProjectKey) {
this.jiraVersion = jiraVersion;
this.jiraProjectKey = jiraProjectKey;
}
@Override
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;
}
public String getJiraVersion() {
return jiraVersion;
}
public void setJiraVersion(String jiraVersion) {
this.jiraVersion = jiraVersion;
}
public String getJiraProjectKey() {
return jiraProjectKey;
}
public void setJiraProjectKey(String jiraProjectKey) {
this.jiraProjectKey = jiraProjectKey;
}
public boolean isFailIfAlreadyExists() {
return failIfAlreadyExists;
}
@DataBoundSetter
public void setFailIfAlreadyExists(boolean failIfAlreadyExists) {
this.failIfAlreadyExists = failIfAlreadyExists;
}
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
VersionCreator versionCreator = new VersionCreator();
versionCreator.setFailIfAlreadyExists(failIfAlreadyExists);
versionCreator.setJiraVersion(jiraVersion);
versionCreator.setJiraProjectKey(jiraProjectKey);
return versionCreator.perform(build.getProject(), build, listener);
}
@Override
public BuildStepDescriptor<Publisher> getDescriptor() {
return DESCRIPTOR;
}
protected Object readResolve() {
if (failIfAlreadyExists == null) {
setFailIfAlreadyExists(true);
}
return this;
}
@Extension
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {
public DescriptorImpl() {
super(JiraVersionCreator.class);
}
@Override
public boolean isApplicable(Class<? extends AbstractProject> jobType) {
return true;
}
@Override
public JiraVersionCreator newInstance(StaplerRequest2 req, JSONObject formData) throws FormException {
return req.bindJSON(JiraVersionCreator.class, formData);
}
@Override
public String getDisplayName() {
return Messages.JiraVersionCreator_DisplayName();
}
@Override
public String getHelpFile() {
return "/plugin/jira/help-version-create.html";
}
}
}