3
3
import hudson .Extension ;
4
4
import hudson .ExtensionList ;
5
5
import hudson .util .FormValidation ;
6
+ import hudson .util .Secret ;
6
7
import jenkins .model .GlobalConfiguration ;
7
8
import org .apache .commons .lang .StringUtils ;
8
9
import org .kohsuke .stapler .DataBoundSetter ;
@@ -21,6 +22,54 @@ public static SampleConfiguration get() {
21
22
22
23
private String label ;
23
24
private String description ;
25
+ private String url ;
26
+ private String userName ;
27
+ private Secret password ;
28
+ private boolean optionalBlock ;
29
+
30
+ public boolean isOptionalBlock () {
31
+ return optionalBlock ;
32
+ }
33
+
34
+ @ DataBoundSetter
35
+ public void setOptionalBlock (boolean optionalBlock ) {
36
+ this .optionalBlock = optionalBlock ;
37
+ save ();
38
+ }
39
+
40
+ public Secret getPassword () {
41
+ return password ;
42
+ }
43
+
44
+ @ DataBoundSetter
45
+ public void setPassword (Secret password ) {
46
+ this .password = password ;
47
+ save ();
48
+ }
49
+
50
+
51
+
52
+ public String getUserName () {
53
+ return userName ;
54
+ }
55
+
56
+ @ DataBoundSetter
57
+ public void setUserName (String userName ) {
58
+ this .userName = userName ;
59
+ save ();
60
+ }
61
+
62
+
63
+
64
+ public String getUrl () {
65
+ return url ;
66
+ }
67
+
68
+ @ DataBoundSetter
69
+ public void setUrl (String url ) {
70
+ this .url = url ;
71
+ save ();
72
+ }
24
73
25
74
public String getDescription () {
26
75
return description ;
@@ -55,8 +104,8 @@ public void setLabel(String label) {
55
104
public FormValidation doCheckLabel (@ QueryParameter String value ) {
56
105
if (StringUtils .isEmpty (value )) {
57
106
return FormValidation .warning ("Please specify a label." );
58
- }else if (!value .matches ("[a-zA-Z] " )) {
59
- return FormValidation .error ( "Only lowercase and uppercase ans spaces are allowed " );
107
+ }if (!value .matches ("[a-zA-Z ]+ " )) {
108
+ return FormValidation .warning ( "Name can only contain letters and spaces. " );
60
109
}
61
110
return FormValidation .ok ();
62
111
}
@@ -66,5 +115,13 @@ public FormValidation doCheckDescription(@QueryParameter String value) {
66
115
}
67
116
return FormValidation .ok ();
68
117
}
118
+ public FormValidation doCheckUserName (@ QueryParameter String value ) {
119
+ if (StringUtils .isEmpty (value )) {
120
+ return FormValidation .warning ("Please specify username" );
121
+ } if (!value .matches ("[a-zA-Z]+" )) {
122
+ return FormValidation .warning ("UserName can only contain letters." );
123
+ }
124
+ return FormValidation .ok ();
125
+ }
69
126
70
127
}
0 commit comments