Skip to content

Commit

Permalink
Merge pull request #5 from tomasz-oponowicz/jenkins-18683
Browse files Browse the repository at this point in the history
[JENKINS-18683] Jenkins 1.522 config changes cannot be saved
  • Loading branch information
gboissinot committed Jul 31, 2013
2 parents 3ef6b01 + 875cb6b commit 35fcd3f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 75 deletions.
63 changes: 62 additions & 1 deletion src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java
Expand Up @@ -12,6 +12,7 @@
import hudson.Extension;
import hudson.ProxyConfiguration;
import hudson.Util;
import hudson.console.AnnotatedLargeText;
import hudson.model.*;
import hudson.util.FormValidation;
import hudson.util.Secret;
Expand All @@ -22,6 +23,7 @@
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.net.ftp.FTPClient;
import org.jenkinsci.lib.envinject.EnvInjectException;
import org.jenkinsci.lib.envinject.service.EnvVarsResolver;
Expand All @@ -45,6 +47,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
Expand Down Expand Up @@ -104,10 +107,68 @@ public Collection<? extends Action> getProjectActions() {
}
}
}
URLTriggerAction action = new URLTriggerAction((AbstractProject) job, getLogFile(), this.getDescriptor().getDisplayName(), subActionTitles);

/*
[JENKINS-18683] Configuration can't be saved.
'job' variable can be undefined during a saving action. The solution is to postpone 'job' usage until
trigger is running. We achieved this by using the URLTriggerAction as nested class (which has access to
class members of the URLTrigger class).
*/
URLTriggerAction action = new URLTriggerAction(this.getDescriptor().getDisplayName(), subActionTitles);
return Collections.singleton(action);
}

public final class URLTriggerAction implements Action {
private transient String label;
private transient Map<String, String> subActionTitle;

public URLTriggerAction(String label, Map<String, String> subActionTitle) {
this.label = label;
this.subActionTitle = subActionTitle;
}

@SuppressWarnings("unused")
public AbstractProject<?, ?> getOwner() {
return (AbstractProject) job;
}

@SuppressWarnings("unused")
public String getLabel() {
return label;
}

@SuppressWarnings("unused")
public String getIconFileName() {
return "clipboard.gif";
}

public String getDisplayName() {
return "URLTrigger Log";
}

@SuppressWarnings("unused")
public String getUrlName() {
return "urltriggerPollLog";
}

@SuppressWarnings("unused")
public String getLog() throws IOException {
return Util.loadFile(getLogFile());
}

@SuppressWarnings("unused")
public Map<String, String> getSubActionTitle() {
return subActionTitle;
}

@SuppressWarnings("unused")
public void writeLogTo(XMLOutput out) throws IOException {
new AnnotatedLargeText<URLTriggerAction>(getLogFile(), Charset.defaultCharset(), true, this).writeHtmlTo(0, out.asWriter());
}

}


private String getURLValue(URLTriggerEntry entry, Node node) throws XTriggerException {
String entryURL = entry.getUrl();
Expand Down

This file was deleted.

0 comments on commit 35fcd3f

Please sign in to comment.