Skip to content

Commit

Permalink
Fixed JENKINS-21066
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen authored and inky84 committed Dec 18, 2013
1 parent 02ae5f5 commit 47ce865
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
Expand Up @@ -54,17 +54,38 @@ public class Poller<C extends AbstractConfiguration> {
protected Launcher launcher;
protected FilePath workspace;
protected TaskListener listener;
protected boolean canPollWhileBuilding = true;

public Poller(AbstractProject<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener) {
this.project = project;
this.launcher = launcher;
this.workspace = workspace;
this.listener = listener;
}

/**
* New constructor. Introduced a field that marks the SCM capable of polling while the project is building.
* @param project
* @param launcher
* @param workspace
* @param listener
* @param canPollWhileBuilding
*/
public Poller(AbstractProject<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener, boolean canPollWhileBuilding) {
this.project = project;
this.launcher = launcher;
this.workspace = workspace;
this.listener = listener;
this.canPollWhileBuilding = canPollWhileBuilding;
}

public PollingResult poll(ConfigurationRotatorBuildAction action) throws AbortException {
PrintStream out = listener.getLogger();
logger.fine(ConfigurationRotator.LOGGERNAME + "Polling started");

if(!canPollWhileBuilding && project.isBuilding()) {
return PollingResult.NO_CHANGES;
}

C configuration = action.getConfiguration();

Expand Down
Expand Up @@ -237,15 +237,13 @@ protected PollingResult compareRemoteRevisionWith( AbstractProject<?, ?> project
// we saw a build was long in the queue, and when started, the polling found
// changed a did schedule the same build with the same changes as last time
// between the last one started and finished.
//Basically this disables polling while the job has a build in the queue.
// Basically this disables polling while the job has a build in the queue.
if( project.isInQueue() ) {
out.println( "A build already in queue - cancelling poll" );
logger.fine( "A build already in queue - cancelling poll" );
return PollingResult.NO_CHANGES;
}




/*
* Determine if the job was reconfigured
*/
Expand Down
Expand Up @@ -31,6 +31,7 @@

import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import net.praqma.clearcase.ucm.entities.Component;
Expand Down Expand Up @@ -94,9 +95,6 @@ public boolean wasReconfigured( AbstractProject<?, ?> project ) {
List<ClearCaseUCMTarget> list = getConfigurationAsTargets( configuration );
for( int i = 0; i < targets.size(); ++i ) {
if( !targets.get( i ).equals( list.get( i ) ) ) {
logger.finest( "Config: " + list.get( i ) );
logger.finest( "Target: " + targets.get( i ) );
logger.fine( "Configuration was not equal" );
return true;
}
}
Expand All @@ -105,9 +103,16 @@ public boolean wasReconfigured( AbstractProject<?, ?> project ) {
return false;
}

/**
* @param project
* @param launcher
* @param workspace
* @param listener
* @return a poller for the scm.
*/
@Override
public Poller getPoller( AbstractProject<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener ) {
return new Poller(project, launcher, workspace, listener );
return new Poller(project, launcher, workspace, listener, false );
}


Expand Down Expand Up @@ -148,9 +153,10 @@ public void createWorkspace( ClearCaseUCMConfiguration configuration ) throws Co
configuration.setView( view );
} catch( Exception e ) {
out.println( ConfigurationRotator.LOGGERNAME + "Unable to create view" );
logger.fine( ConfigurationRotator.LOGGERNAME + "Unable to create view, message is: "
+ e.getMessage() + ". Cause was: " + ( e.getCause() == null ? "unknown" : e.getCause().getMessage() ) );
throw new ConfigurationRotatorException( "Unable to create view", e );

ConfigurationRotatorException ex = new ConfigurationRotatorException( "Unable to create view", e );
logger.log(Level.SEVERE, "Unable to create view in createWorkspace()", ex);
throw ex;
}
}

Expand Down Expand Up @@ -257,7 +263,6 @@ public AbstractConfiguration nextConfiguration( TaskListener listener, AbstractC
for( ClearCaseUCMConfigurationComponent config : nconfig.getList() ) {
/* This configuration is not fixed */
if( !config.isFixed() ) {
logger.fine( ConfigurationRotator.LOGGERNAME + "Wasn't fixed: " + config.getBaseline().getNormalizedName() );

try {
//current = workspace.act( new GetBaselines( listener, config.getBaseline().getComponent(), config.getBaseline().getStream(), config.getPlevel(), 1, config.getBaseline() ) ).get( 0 ); //.get(0) newest baseline, they are sorted!
Expand Down

0 comments on commit 47ce865

Please sign in to comment.