Skip to content

Commit

Permalink
Fix JENKINS-14104
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed Jun 16, 2012
1 parent 2043d84 commit 01fdc98
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 14 deletions.
Expand Up @@ -17,17 +17,26 @@
*/
public abstract class AbstractTrigger extends org.jenkinsci.lib.xtrigger.AbstractTrigger {

protected boolean labelRestriction;

protected boolean enableConcurrentBuild;

public AbstractTrigger(String cronTabSpec, boolean enableConcurrentBuild) throws ANTLRException {
super(cronTabSpec, enableConcurrentBuild);
public AbstractTrigger(String cronTabSpec, boolean labelRestriction, String triggerLabel, boolean enableConcurrentBuild) throws ANTLRException {
super(cronTabSpec, triggerLabel, enableConcurrentBuild);
this.labelRestriction = labelRestriction;
this.enableConcurrentBuild = enableConcurrentBuild;
}

@SuppressWarnings("unused")
public boolean isEnableConcurrentBuild() {
return enableConcurrentBuild;
}

@SuppressWarnings("unused")
public boolean isLabelRestriction() {
return labelRestriction;
}

@Override
protected void start(Node pollingNode, BuildableItem project, boolean newInstance, XTriggerLog log) {
}
Expand Down
@@ -0,0 +1,20 @@
package org.jenkinsci.plugins.scripttrigger;

import org.kohsuke.stapler.DataBoundConstructor;

/**
* @author Gregory Boissinot
*/
public class LabelRestrictionClass {

private String triggerLabel;

@DataBoundConstructor
public LabelRestrictionClass(String triggerLabel) {
this.triggerLabel = triggerLabel;
}

public String getTriggerLabel() {
return triggerLabel;
}
}
Expand Up @@ -26,9 +26,10 @@ public class ScriptTrigger extends AbstractTrigger {

private String exitCode;


@DataBoundConstructor
public ScriptTrigger(String cronTabSpec, boolean enableConcurrentBuild, String script, String scriptFilePath, String exitCode) throws ANTLRException {
super(cronTabSpec, enableConcurrentBuild);
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);
this.script = Util.fixEmpty(script);
this.scriptFilePath = Util.fixEmpty(scriptFilePath);
this.exitCode = Util.fixEmpty(exitCode);
Expand All @@ -44,6 +45,11 @@ public String getScriptFilePath() {
return scriptFilePath;
}

@SuppressWarnings("unused")
public String getExitCode() {
return exitCode;
}

@Override
public Collection<? extends Action> getProjectActions() {
ScriptTriggerAction action = new ScriptTriggerAction((AbstractProject) job, getLogFile(), getDescriptor().getDisplayName());
Expand Down
Expand Up @@ -14,6 +14,7 @@
import org.jenkinsci.lib.xtrigger.XTriggerDescriptor;
import org.jenkinsci.lib.xtrigger.XTriggerLog;
import org.jenkinsci.plugins.scripttrigger.AbstractTrigger;
import org.jenkinsci.plugins.scripttrigger.LabelRestrictionClass;
import org.jenkinsci.plugins.scripttrigger.ScriptTriggerException;
import org.kohsuke.stapler.DataBoundConstructor;

Expand All @@ -38,8 +39,8 @@ public class GroovyScriptTrigger extends AbstractTrigger {

@DataBoundConstructor
@SuppressWarnings("unused")
public GroovyScriptTrigger(String cronTabSpec, boolean enableConcurrentBuild, String groovyExpression, String groovyFilePath, String propertiesFilePath, boolean groovySystemScript) throws ANTLRException {
super(cronTabSpec, enableConcurrentBuild);
public GroovyScriptTrigger(String cronTabSpec, LabelRestrictionClass labelRestriction, boolean enableConcurrentBuild, String groovyExpression, String groovyFilePath, String propertiesFilePath, boolean groovySystemScript) throws ANTLRException {
super(cronTabSpec, (labelRestriction == null) ? false : true, (labelRestriction == null) ? null : labelRestriction.getTriggerLabel(), enableConcurrentBuild);
this.groovyExpression = Util.fixEmpty(groovyExpression);
this.groovyFilePath = Util.fixEmpty(groovyFilePath);
this.propertiesFilePath = Util.fixEmpty(propertiesFilePath);
Expand Down
Expand Up @@ -12,14 +12,34 @@
<f:textbox name="exitCode" value="${instance.exitCode}"/>
</f:entry>

<f:entry field="enableConcurrentBuild" title="${%Enable Concurrent Build}">
<f:checkbox name="enableConcurrentBuild" checked="${instance.enableConcurrentBuild}"/>
</f:entry>

<f:entry title="${%Polling Node}">
<f:entry>
<table style="width:100%">
<f:optionalBlock
name="labelRestriction"
field="labelRestriction"
checked="${instance.labelRestriction}"
title="${%Restrict where the polling can be run}">

<f:block>
<f:entry title="Label Expression">
<f:textbox name="triggerLabel"
value="${instance.triggerLabel}"/>
</f:entry>
</f:block>
</f:optionalBlock>
</table>
</f:entry>
</f:entry>

<f:entry title="${%Schedule}" help="/descriptor/hudson.triggers.TimerTrigger/help/spec">
<f:textarea name="cronTabSpec"
checkUrl="'${rootURL}/trigger/TimerTrigger/check?value='+encodeURIComponent(this.value)"
value="${instance.spec}"/>
</f:entry>

<f:entry field="enableConcurrentBuild" title="${%Enable Concurrent Build}">
<f:checkbox name="enableConcurrentBuild" checked="${instance.enableConcurrentBuild}"/>
</f:entry>

</j:jelly>
Expand Up @@ -18,14 +18,34 @@
</f:entry>
</f:advanced>

<f:entry field="enableConcurrentBuild" title="${%Enable Concurrent Build}">
<f:checkbox name="enableConcurrentBuild" checked="${instance.enableConcurrentBuild}"/>
</f:entry>

<f:entry title="${%Polling Node}">
<f:entry>
<table style="width:100%">
<f:optionalBlock
name="labelRestriction"
field="labelRestriction"
checked="${instance.labelRestriction}"
title="${%Restrict where the polling can be run}">

<f:block>
<f:entry title="Label Expression">
<f:textbox name="triggerLabel"
value="${instance.triggerLabel}"/>
</f:entry>
</f:block>
</f:optionalBlock>
</table>
</f:entry>
</f:entry>

<f:entry title="${%Schedule}" help="/descriptor/hudson.triggers.TimerTrigger/help/spec">
<f:textarea name="cronTabSpec"
checkUrl="'${rootURL}/trigger/TimerTrigger/check?value='+encodeURIComponent(this.value)"
value="${instance.spec}"/>
</f:entry>

<f:entry field="enableConcurrentBuild" title="${%Enable Concurrent Build}">
<f:checkbox name="enableConcurrentBuild" checked="${instance.enableConcurrentBuild}"/>
</f:entry>

</j:jelly>

0 comments on commit 01fdc98

Please sign in to comment.