Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-26175] Exclusive execution mode can now be configured to
skip waiting for currently running jobs
[FIXED JENKINS-24854] Shutdown mode is now also cancelled if job is
canceled in pre-build phase
[FIXED JENKINS-26351] Spanish translation added
  • Loading branch information
fmiguelez committed Jan 9, 2015
1 parent 36e4db8 commit 6ce7ef5
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 15 deletions.
Expand Up @@ -46,33 +46,58 @@
* @author Sam Tavakoli
*/
public class ExclusiveBuildWrapper extends BuildWrapper {

private boolean skipWait;

@DataBoundConstructor
public ExclusiveBuildWrapper(boolean enabled) {
public ExclusiveBuildWrapper(boolean enabled, boolean skipWait) {
super();
this.skipWait = skipWait;
}

public boolean isSkipWait()
{
return skipWait;
}

@Override
public BuildWrapper.Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener)
throws InterruptedException{
String nodeName = Computer.currentComputer().getDisplayName();

DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_executingOn() + nodeName);
DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_executingOn() + " " + nodeName);
DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_shutdownMessage());

try {
Jenkins.getInstance().doQuietDown();
} catch (IOException e) {
DebugHelper.fatalError(listener, Messages.ExclusiveBuildWrapper_errorQuietMode() +
DebugHelper.fatalError(listener, Messages.ExclusiveBuildWrapper_errorQuietMode() + " " +
e.getMessage());
e.printStackTrace(listener.getLogger());
}

while (areComputersIdle(nodeName, Jenkins.getInstance().getComputers()) == false) {
Thread.sleep(500);
if(skipWait)
{
DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_waitSkipped());
}

DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_onlyJobRunning());
else
{
DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_waiting());
while (areComputersIdle(nodeName, Jenkins.getInstance().getComputers()) == false) {
try
{
Thread.sleep(500);
}
catch(InterruptedException e) {
// Gracefully cancel shutdown if job is canceled in pre-build phase
cancelShutdown(listener);
throw e;
}
}

DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_onlyJobRunning());
}

return new ExclusiveEnvironment(listener);
}

Expand Down Expand Up @@ -113,6 +138,12 @@ public boolean isApplicable(AbstractProject item) {
}
}

private void cancelShutdown(BuildListener listener)
{
DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_cancelShutDownMode());
Jenkins.getInstance().doCancelQuietDown();
}

/**
* handles the post-build tasks such as canceling the quiet down sequencing
*
Expand All @@ -126,10 +157,9 @@ public ExclusiveEnvironment(BuildListener listener) {

@Override
public boolean tearDown(AbstractBuild build, BuildListener listener) {
DebugHelper.info(listener, Messages.ExclusiveBuildWrapper_cancelShutDownMode());
Jenkins.getInstance().doCancelQuietDown();

cancelShutdown(listener);
return true;
}
}

}
@@ -1,6 +1,5 @@
<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">
<!--f:entry title="${%Title}" help="/plugin/execution/exclusive/help-projectConfig.html"
description="${%Description}">
<f:checkbox name="exclusive.enabled" checked="${instance.enabled}" />
</f:entry-->
<f:entry field="skipWait">
<f:checkbox title="${%Do not wait till running jobs end}"/>
</f:entry>
</j:jelly>
@@ -0,0 +1 @@
Do\ not\ wait\ till\ running\ jobs\ end=No esperar a que terminen los trabajos en ejecución
@@ -1,6 +1,8 @@
ExclusiveBuildWrapper.DisplayName=Set exclusive execution
ExclusiveBuildWrapper.shutdownMessage=Putting Jenkins in shutdown mode...
ExclusiveBuildWrapper.executingOn=Executing on
ExclusiveBuildWrapper.executingOn=Executing on
ExclusiveBuildWrapper.errorQuietMode=Couldn't put Jenkins in quiet mode,
ExclusiveBuildWrapper.onlyJobRunning=Only this job is running; starting execution...
ExclusiveBuildWrapper.waiting=Waiting for running jobs...
ExclusiveBuildWrapper.waitSkipped=Waiting for running jobs skipped; starting execution...
ExclusiveBuildWrapper.cancelShutDownMode=Canceling Jenkins shutdown mode...
@@ -0,0 +1,8 @@
ExclusiveBuildWrapper.DisplayName=Activar ejecución exclusiva
ExclusiveBuildWrapper.shutdownMessage=Poniendo Jenkins en modo apagado...
ExclusiveBuildWrapper.executingOn=Ejecutando en
ExclusiveBuildWrapper.errorQuietMode=No se pudo poner Jenkins en modo silencioso,
ExclusiveBuildWrapper.onlyJobRunning=Éste es el único trabajo en ejecución; comenzando ejecución...
ExclusiveBuildWrapper.waiting=Esperando finalización de trabajos en ejecución...
ExclusiveBuildWrapper.waitSkipped=Espera de finalización de trabajos en ejecución omitida; comenzando ejecución...
ExclusiveBuildWrapper.cancelShutDownMode=Cancelando el modo apagado de Jenkins...

0 comments on commit 6ce7ef5

Please sign in to comment.