Skip to content

Commit

Permalink
Fix JENKINS-16841
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed Feb 24, 2013
1 parent be9e505 commit 49673bf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
Expand Up @@ -54,7 +54,7 @@ private void processAndScheduleIfNeeded(TopLevelItem item, Computer c, TaskListe
HudsonStartupService startupService = new HudsonStartupService();
if (startupService.has2Schedule(startupTrigger, node)) {
listener.getLogger().print("[StartupTrigger] - Scheduling " + project.getName());
project.scheduleBuild(0, new HudsonStartupCause());
project.scheduleBuild(startupTrigger.getQuietPeriod(), new HudsonStartupCause());
}
}

Expand Down
Expand Up @@ -22,18 +22,31 @@ public class HudsonStartupTrigger extends Trigger<BuildableItem> {

private String label;

private int quietPeriod;

@DataBoundConstructor
public HudsonStartupTrigger(String label) throws ANTLRException {
public HudsonStartupTrigger(String label, String quietPeriod) throws ANTLRException {
super();
this.label = Util.fixEmpty(label);
String givenQuietPeriod = Util.fixEmpty(quietPeriod);
if (givenQuietPeriod == null) {
this.quietPeriod = 0;
} else {
this.quietPeriod = Integer.parseInt(quietPeriod);
}
}

public String getLabel() {
return label;
}

public int getQuietPeriod() {
return quietPeriod;
}

@Override
public void start(BuildableItem project, boolean newInstance) {
//DO NOTHING HERE. RELIES ON EXTERNAL LISTENER
}

@Extension
Expand Down
@@ -1,7 +1,11 @@
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">

<f:entry field="label" title="${%Node Label}">
<f:entry field="label" title="${%Restricted node Label}">
<f:textbox name="label" value="${instance.label}"/>
</f:entry>

<f:entry field="quietPeriod" title="${%Quiet period}">
<f:textbox name="quietPeriod" value="${instance.quietPeriod}"/>
</f:entry>

</j:jelly>
Expand Up @@ -2,7 +2,7 @@
<p>
By default, the build is triggered when Jenkins instance starts.<br/>
You can specify a specific a node name or a node label to trigger a build when nodes (whose names or labels
corresponding to the specified value) start. <br/>.
corresponding to the specified value) start. <br/>
You can also specify the 'master' value to refer explicitly to Jenkins master.
</p>
</div>
@@ -0,0 +1,7 @@
<div>
<p>
Give the quiet period before scheduling the job.<br/>
The time unit is in seconds.<br/>
'0' is the default value, the job is scheduling without any delay at startup.
</p>
</div>

0 comments on commit 49673bf

Please sign in to comment.