Skip to content

Commit

Permalink
make mattermost plugin compliant with JCasC
Browse files Browse the repository at this point in the history
  • Loading branch information
ewelinawilkosz committed Nov 23, 2018
1 parent 8bedb91 commit f8a52af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
37 changes: 23 additions & 14 deletions src/main/java/jenkins/plugins/mattermost/MattermostNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,38 @@ public DescriptorImpl() {
load();
}

@DataBoundSetter
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}

public String getEndpoint() {
return endpoint;
}

@DataBoundSetter
public void setRoom(String room) {
this.room = room;
}

public String getRoom() {
return room;
}

@DataBoundSetter
public void setIcon(String icon) {
this.icon = icon;
}

public String getIcon() {
return icon;
}

@DataBoundSetter
public void setBuildServerUrl(String buildServerUrl) {
this.buildServerUrl = buildServerUrl;
}

public String getBuildServerUrl() {
if (buildServerUrl == null || buildServerUrl.equals("")) {
JenkinsLocationConfiguration jenkinsConfig = new JenkinsLocationConfiguration();
Expand Down Expand Up @@ -395,21 +415,10 @@ public MattermostNotifier newInstance(StaplerRequest sr, JSONObject json) {
}

@Override
public boolean configure(StaplerRequest sr, JSONObject formData) throws FormException {
endpoint = sr.getParameter("mattermostEndpoint");
room = sr.getParameter("mattermostRoom");
icon = sr.getParameter("mattermostIcon");
buildServerUrl = sr.getParameter("mattermostBuildServerUrl");
sendAs = sr.getParameter("mattermostSendAs");
if (buildServerUrl == null || buildServerUrl.equals("")) {
JenkinsLocationConfiguration jenkinsConfig = new JenkinsLocationConfiguration();
buildServerUrl = jenkinsConfig.getUrl();
}
if (buildServerUrl != null && !buildServerUrl.endsWith("/")) {
buildServerUrl = buildServerUrl + "/";
}
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
req.bindJSON(this, json);
save();
return super.configure(sr, formData);
return true;
}

MattermostService getMattermostService(final String endpoint, final String room, final String icon) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
-->
<f:section title="Global Mattermost Notifier Settings" name="mattermost">
<f:entry title="Endpoint" help="${rootURL}/plugin/mattermost/help-globalConfig-mattermostEndpoint.html">
<f:textbox field="endpoint" name="mattermostEndpoint" value="${descriptor.getEndpoint()}" />
<f:textbox field="endpoint" value="${descriptor.getEndpoint()}" />
</f:entry>
<f:entry title="Channel" help="${rootURL}/plugin/mattermost/help-globalConfig-mattermostRoom.html">
<f:textbox field="room" name="mattermostRoom" value="${descriptor.getRoom()}" />
<f:textbox field="room" value="${descriptor.getRoom()}" />
</f:entry>
<f:entry title="Icon to use" help="${rootURL}/plugin/mattermost/help-globalConfig-mattermostIcon.html">
<f:textbox field="icon" name="mattermostIcon" value="${descriptor.getIcon()}" />
<f:textbox field="icon" value="${descriptor.getIcon()}" />
</f:entry>
<f:entry title="Build Server URL" help="${rootURL}/plugin/mattermost/help-globalConfig-mattermostBuildServerUrl.html">
<f:textbox field="buildServerUrl" name="mattermostBuildServerUrl" value="${descriptor.getBuildServerUrl()}" />
<f:textbox field="buildServerUrl" value="${descriptor.getBuildServerUrl()}" />
</f:entry>
<f:validateButton
title="${%Test Connection}" progress="${%Testing...}"
Expand Down

0 comments on commit f8a52af

Please sign in to comment.