Skip to content

Commit

Permalink
rename HelloWorldBuilder to NTFYNotifierBuilder, add serverURL and to…
Browse files Browse the repository at this point in the history
…pic global variable
  • Loading branch information
VardyNg committed Sep 15, 2023
1 parent c1bb332 commit e9e1a84
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;

public class HelloWorldBuilder extends Builder implements SimpleBuildStep {
public class NTFYNotifierBuilder extends Builder implements SimpleBuildStep {

private final String name;
private final String serverURL;
private final String topic;
private boolean useFrench;

@DataBoundConstructor
public HelloWorldBuilder(String name) {
this.name = name;
public NTFYNotifierBuilder(String serverURL, String topic) {
this.serverURL = serverURL;
this.topic = topic;
}

public String getName() {
return name;
public String getServerURL() {
return serverURL;
}

public String getTopic() {
return topic;
}

public boolean isUseFrench() {
Expand All @@ -45,9 +51,9 @@ public void setUseFrench(boolean useFrench) {
public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher launcher, TaskListener listener)
throws InterruptedException, IOException {
if (useFrench) {
listener.getLogger().println("Bonjour, " + name + "!");
listener.getLogger().println("Bonjour, " + serverURL + "!");
} else {
listener.getLogger().println("Hello, " + name + "!");
listener.getLogger().println("Sending message to https://" + serverURL + "/" + topic);
}
}

Expand All @@ -58,11 +64,11 @@ public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
public FormValidation doCheckName(@QueryParameter String value, @QueryParameter boolean useFrench)
throws IOException, ServletException {
if (value.length() == 0)
return FormValidation.error(Messages.HelloWorldBuilder_DescriptorImpl_errors_missingName());
return FormValidation.error(Messages.NTFYNotifyBuilder_DescriptorImpl_errors_missingName());
if (value.length() < 4)
return FormValidation.warning(Messages.HelloWorldBuilder_DescriptorImpl_warnings_tooShort());
return FormValidation.warning(Messages.NTFYNotifyBuilder_DescriptorImpl_warnings_tooShort());
if (!useFrench && value.matches(".*[éáàç].*")) {
return FormValidation.warning(Messages.HelloWorldBuilder_DescriptorImpl_warnings_reallyFrench());
return FormValidation.warning(Messages.NTFYNotifyBuilder_DescriptorImpl_warnings_reallyFrench());
}
return FormValidation.ok();
}
Expand All @@ -74,7 +80,7 @@ public boolean isApplicable(Class<? extends AbstractProject> aClass) {

@Override
public String getDisplayName() {
return Messages.HelloWorldBuilder_DescriptorImpl_DisplayName();
return Messages.NTFYNotifyBuilder_DescriptorImpl_DisplayName();
}
}
}

0 comments on commit e9e1a84

Please sign in to comment.