Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix JENKINS-18667
  • Loading branch information
gboissinot committed Aug 1, 2013
1 parent 44ddb72 commit 86b61ff
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 140 deletions.

This file was deleted.

Expand Up @@ -3,14 +3,18 @@
import antlr.ANTLRException;
import hudson.Extension;
import hudson.Util;
import hudson.console.AnnotatedLargeText;
import hudson.model.*;
import org.apache.commons.jelly.XMLOutput;
import org.jenkinsci.lib.envinject.EnvInjectException;
import org.jenkinsci.lib.envinject.service.EnvVarsResolver;
import org.jenkinsci.lib.xtrigger.XTriggerDescriptor;
import org.jenkinsci.lib.xtrigger.XTriggerLog;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
Expand All @@ -26,7 +30,6 @@ public class ScriptTrigger extends AbstractTrigger {

private String exitCode;


@DataBoundConstructor
public ScriptTrigger(String cronTabSpec, LabelRestrictionClass labelRestriction, boolean enableConcurrentBuild, String script, String scriptFilePath, String exitCode) throws ANTLRException {
super(cronTabSpec, (labelRestriction == null) ? false : true, (labelRestriction == null) ? null : labelRestriction.getTriggerLabel(), enableConcurrentBuild);
Expand All @@ -52,10 +55,54 @@ public String getExitCode() {

@Override
public Collection<? extends Action> getProjectActions() {
ScriptTriggerAction action = new ScriptTriggerAction((AbstractProject) job, getLogFile(), getDescriptor().getDisplayName());
ScriptTriggerAction action = new InternalScriptTriggerAction(getDescriptor().getDisplayName());
return Collections.singleton(action);
}

public final class InternalScriptTriggerAction extends ScriptTriggerAction {

private transient String actionTitle;

public InternalScriptTriggerAction(String actionTitle) {
this.actionTitle = actionTitle;
}

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

@Override
public String getDisplayName() {
return "ScriptTrigger Log";
}

@Override
public String getUrlName() {
return "scripttriggerPollLog";
}

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

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

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

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

@Override
public ScriptTrigger.ScriptTriggerDescriptor getDescriptor() {
return (ScriptTrigger.ScriptTriggerDescriptor) Hudson.getInstance().getDescriptorOrDie(getClass());
Expand Down
@@ -1,30 +1,11 @@
package org.jenkinsci.plugins.scripttrigger;

import hudson.model.AbstractProject;

import java.io.File;
import hudson.model.Action;

/**
* Marked Action class
*
* @author Gregory Boissinot
*/
public class ScriptTriggerAction extends AbstractTriggerAction {

public ScriptTriggerAction(AbstractProject<?, ?> job, File logFile, String label) {
super(job, logFile, label);
}

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

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

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

public abstract class ScriptTriggerAction implements Action {
}
Expand Up @@ -4,11 +4,13 @@
import hudson.Extension;
import hudson.FilePath;
import hudson.Util;
import hudson.console.AnnotatedLargeText;
import hudson.model.*;
import hudson.remoting.VirtualChannel;
import hudson.security.ACL;
import org.acegisecurity.Authentication;
import org.acegisecurity.context.SecurityContextHolder;
import org.apache.commons.jelly.XMLOutput;
import org.jenkinsci.lib.envinject.EnvInjectException;
import org.jenkinsci.lib.envinject.service.EnvVarsResolver;
import org.jenkinsci.lib.xtrigger.XTriggerDescriptor;
Expand All @@ -21,6 +23,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.*;


Expand Down Expand Up @@ -68,10 +71,55 @@ public boolean isGroovySystemScript() {

@Override
public Collection<? extends Action> getProjectActions() {
GroovyScriptTriggerAction action = new GroovyScriptTriggerAction((AbstractProject) job, getLogFile(), getDescriptor().getDisplayName());
GroovyScriptTriggerAction action = new InternalGroovyScriptTriggerAction(getDescriptor().getDisplayName());
return Collections.singleton(action);
}

public final class InternalGroovyScriptTriggerAction extends GroovyScriptTriggerAction {

private transient String actionTitle;

public InternalGroovyScriptTriggerAction(String actionTitle) {
this.actionTitle = actionTitle;
}

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

@Override
public String getDisplayName() {
return "GroovyScriptTrigger Log";
}

@Override
public String getUrlName() {
return "groovyScripttriggerPollLog";
}

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

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

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

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


@Override
protected File getLogFile() {
return new File(job.getRootDir(), "groovyScriptTrigger-polling.log");
Expand Down
@@ -1,31 +1,10 @@
package org.jenkinsci.plugins.scripttrigger.groovy;

import hudson.model.AbstractProject;
import org.jenkinsci.plugins.scripttrigger.AbstractTriggerAction;

import java.io.File;
import hudson.model.Action;

/**
* @author Gregory Boissinot
*/
public class GroovyScriptTriggerAction extends AbstractTriggerAction {

public GroovyScriptTriggerAction(AbstractProject<?, ?> job, File logFile, String label) {
super(job, logFile, label);
}

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

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

@SuppressWarnings("unused")
public String getUrlName() {
return "groovyScripttriggerPollLog";
}
public abstract class GroovyScriptTriggerAction implements Action {

}
2 changes: 1 addition & 1 deletion src/main/resources/index.jelly
@@ -1,3 +1,3 @@
<div>
This plugin makes it possible to poll changes of an environment with a script.
This plugin makes it possible to poll changes of an environment with a script.
</div>
Expand Up @@ -22,23 +22,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout>
<st:include it="${it.owner}" page="sidepanel.jelly" />
<l:main-panel>
<h1>${it.label}</h1>
<j:set var="log" value="${it.log}" />
<j:choose>
<j:when test="${empty(log)}">
${%Polling has not run yet.}
</j:when>
<j:otherwise>
<pre>
<st:getOutput var="output" />
<j:whitespace>${it.writeLogTo(output)}</j:whitespace>
</pre>
</j:otherwise>
</j:choose>
</l:main-panel>
</l:layout>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout>
<st:include it="${it.owner}" page="sidepanel.jelly"/>
<l:main-panel>
<h1>${it.label}</h1>
<j:set var="log" value="${it.log}"/>
<j:choose>
<j:when test="${empty(log)}">
${%Polling has not run yet.}
</j:when>
<j:otherwise>
<pre>
<st:getOutput var="output"/>
<j:whitespace>${it.writeLogTo(output)}</j:whitespace>
</pre>
</j:otherwise>
</j:choose>
</l:main-panel>
</l:layout>
</j:jelly>
Expand Up @@ -22,23 +22,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout>
<st:include it="${it.owner}" page="sidepanel.jelly" />
<l:main-panel>
<h1>${it.label}</h1>
<j:set var="log" value="${it.log}" />
<j:choose>
<j:when test="${empty(log)}">
${%Polling has not run yet.}
</j:when>
<j:otherwise>
<pre>
<st:getOutput var="output" />
<j:whitespace>${it.writeLogTo(output)}</j:whitespace>
</pre>
</j:otherwise>
</j:choose>
</l:main-panel>
</l:layout>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout>
<st:include it="${it.owner}" page="sidepanel.jelly"/>
<l:main-panel>
<h1>${it.label}</h1>
<j:set var="log" value="${it.log}"/>
<j:choose>
<j:when test="${empty(log)}">
${%Polling has not run yet.}
</j:when>
<j:otherwise>
<pre>
<st:getOutput var="output"/>
<j:whitespace>${it.writeLogTo(output)}</j:whitespace>
</pre>
</j:otherwise>
</j:choose>
</l:main-panel>
</l:layout>
</j:jelly>

0 comments on commit 86b61ff

Please sign in to comment.