Skip to content

Commit

Permalink
Leve 2
Browse files Browse the repository at this point in the history
  • Loading branch information
SNanda8895 committed Jul 30, 2024
1 parent 6c81f21 commit 0cf6b8c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/io/jenkins/plugins/sample/SampleConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ public static SampleConfiguration get() {
}

private String label;
private String description;

public String getDescription() {
return description;
}

@DataBoundSetter
public void setDescription(String description) {
this.description = description;
save();
}

public SampleConfiguration() {
// When Jenkins is restarted, load any saved configuration from disk.
Expand All @@ -44,7 +55,16 @@ public void setLabel(String label) {
public FormValidation doCheckLabel(@QueryParameter String value) {
if (StringUtils.isEmpty(value)) {
return FormValidation.warning("Please specify a label.");
}else if (!value.matches("[a-zA-Z]")) {
return FormValidation.error("Only lowercase and uppercase ans spaces are allowed");
}
return FormValidation.ok();
}
public FormValidation doCheckDescription(@QueryParameter String value) {
if (StringUtils.isEmpty(value)) {
return FormValidation.warning("Please specify a description.");
}
return FormValidation.ok();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<f:entry field="label" title="${%Label}">
<f:textbox/>
</f:entry>
<f:entry field="description" title="${%Description}">
<f:textarea/>
</f:entry>
</f:section>
</j:jelly>

0 comments on commit 0cf6b8c

Please sign in to comment.