-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathGitSCMStatusChecksExtension.java
More file actions
131 lines (112 loc) · 3.53 KB
/
GitSCMStatusChecksExtension.java
File metadata and controls
131 lines (112 loc) · 3.53 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
120
121
122
123
124
125
126
127
128
129
130
131
package io.jenkins.plugins.checks.github.status;
import io.jenkins.plugins.checks.github.GitHubChecksGlobalConfig;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import hudson.Extension;
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor;
import hudson.util.FormValidation;
import io.jenkins.plugins.checks.status.AbstractStatusChecksProperties;
/**
* Git Extension that controls {@link AbstractStatusChecksProperties} for freestyle jobs using {@link hudson.plugins.git.GitSCM}.
*/
@SuppressWarnings("PMD.DataClass")
public class GitSCMStatusChecksExtension extends GitSCMExtension implements GitHubStatusChecksConfigurations {
private boolean skip = false;
private boolean unstableBuildNeutral = false;
private String name = "Jenkins";
private boolean suppressLogs;
private boolean skipProgressUpdates = false;
public boolean enforceSkipProgressUpdates = GitHubChecksGlobalConfig.get().isEnforceSkipProgressUpdates();
/**
* Constructor for stapler.
*/
@DataBoundConstructor
public GitSCMStatusChecksExtension() {
super();
}
@Override
public String getName() {
return name;
}
@Override
public boolean isSkip() {
return skip;
}
@Override
public boolean isUnstableBuildNeutral() {
return unstableBuildNeutral;
}
@Override
public boolean isSuppressLogs() {
return suppressLogs;
}
@Override
public boolean isSkipProgressUpdates() {
return skipProgressUpdates;
}
@Override
public boolean isEnforceSkipProgressUpdates() { return enforceSkipProgressUpdates; }
@DataBoundSetter
public void setSkipProgressUpdates(final boolean skipProgressUpdates) {
this.skipProgressUpdates = skipProgressUpdates;
}
/**
* Set the name of the status checks.
*
* @param name
* name of the checks
*/
@DataBoundSetter
public void setName(final String name) {
this.name = name;
}
/**
* Set if skip publishing status checks.
*
* @param skip
* true if skip
*/
@DataBoundSetter
public void setSkip(final boolean skip) {
this.skip = skip;
}
@DataBoundSetter
public void setUnstableBuildNeutral(final boolean unstableBuildNeutral) {
this.unstableBuildNeutral = unstableBuildNeutral;
}
@DataBoundSetter
public void setSuppressLogs(final boolean suppressLogs) {
this.suppressLogs = suppressLogs;
}
/**
* Descriptor implementation for {@link GitSCMStatusChecksExtension}.
*/
@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
/**
* Returns the display name.
*
* @return "Status Checks Properties"
*/
@Override
public String getDisplayName() {
return "Status Checks Properties";
}
/**
* Checks if the name of status checks is valid.
*
* @param name
* name of status checks
* @return ok if the name is not empty
*/
public FormValidation doCheckName(@QueryParameter final String name) {
if (StringUtils.isBlank(name)) {
return FormValidation.error("Name should not be empty!");
}
return FormValidation.ok();
}
}
}