Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply global config #26

Merged
merged 1 commit into from
Feb 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/jenkins/plugins/slack/SlackListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ FineGrainedNotifier getNotifier(AbstractProject project) {
Map<Descriptor<Publisher>, Publisher> map = project.getPublishersList().toMap();
for (Publisher publisher : map.values()) {
if (publisher instanceof SlackNotifier) {
((SlackNotifier)publisher).update();
return new ActiveNotifier((SlackNotifier) publisher);
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/jenkins/plugins/slack/SlackNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
return true;
}

public void update() {
this.teamDomain = getDescriptor().teamDomain;
this.authToken = getDescriptor().token;
this.buildServerUrl = getDescriptor().buildServerUrl;
this.room = getDescriptor().room;
this.sendAs = getDescriptor().sendAs;
}

@Extension
public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {
private String teamDomain;
Expand Down Expand Up @@ -133,11 +141,6 @@ public boolean configure(StaplerRequest sr, JSONObject formData) throws FormExce
if (buildServerUrl != null && !buildServerUrl.endsWith("/")) {
buildServerUrl = buildServerUrl + "/";
}
try {
new SlackNotifier(teamDomain, token, room, buildServerUrl, sendAs);
} catch (Exception e) {
throw new FormException("Failed to initialize notifier - check your global notifier configuration settings", e, "");
}
save();
return super.configure(sr, formData);
}
Expand Down Expand Up @@ -200,6 +203,7 @@ public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
for (Publisher publisher : map.values()) {
if (publisher instanceof SlackNotifier) {
logger.info("Invoking Started...");
((SlackNotifier)publisher).update();
new ActiveNotifier((SlackNotifier) publisher).started(build);
}
}
Expand Down