Skip to content

Commit

Permalink
Fixed a couple of issues related to JENKINS-26985
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen committed Apr 13, 2015
1 parent 8007904 commit 7c90c3e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 16 deletions.
12 changes: 10 additions & 2 deletions src/main/java/net/praqma/hudson/notifier/CCUCMNotifier.java
Expand Up @@ -246,6 +246,7 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
try {
out.println( String.format("%s Trying to cancel the deliver.", logShortPrefix) );
//out.print( "[" + Config.nameShort + "] Trying to cancel the deliver. " );

RemoteUtil.completeRemoteDeliver( currentWorkspace, listener, pstate.getBaseline(), pstate.getStream(), action.getViewTag(), action.getViewPath(), false );
out.println( "Success." );
} catch( Exception e1 ) {
Expand Down Expand Up @@ -274,7 +275,6 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
out.println( String.format( "%s Absolute path of remoteWorkspace: %s", logShortPrefix, workspace ) );
pstate.setWorkspace( workspace );
NameTemplate.validateTemplates( pstate, build.getWorkspace() );
//TODO: Fix this tomorrow!
String name = NameTemplate.parseTemplate( pstate.getNameTemplate(), pstate, build.getWorkspace() );
targetbaseline = RemoteUtil.createRemoteBaseline( currentWorkspace, name, pstate.getStream(), pstate.getViewPath() );
action.setCreatedBaseline( targetbaseline );
Expand All @@ -284,10 +284,18 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
out.println(String.format( "%s The build failed, cancelling rebase", logShortPrefix));
build.getWorkspace().act(new RebaseCancelTask(pstate.getStream()));
}
} catch (TemplateException templex) {
out.println( String.format("%s %s", logShortPrefix, templex.getMessage() ) );
logger.warning( "Failing build because baseline could not be created in poll rebase" );
pstate.setRecommend(false);
build.setResult( Result.FAILURE );
} catch (Exception ex) {
Throwable cause = net.praqma.util.ExceptionUtils.unpackFrom( IOException.class, ex );
out.println( String.format( "%s Rebase opration failed", logShortPrefix ) );
out.println( String.format( "%s Rebase operation failed", logShortPrefix ) );
ExceptionUtils.print( cause, out, true );
pstate.setRecommend(false);
logger.warning( "Failing build because baseline could not be created in poll rebase" );
build.setResult( Result.FAILURE );
}

/* Remote post build step, common to all types */
Expand Down
75 changes: 62 additions & 13 deletions src/main/java/net/praqma/hudson/scm/CCUCMScm.java
Expand Up @@ -180,8 +180,8 @@ public Object readResolve() {
if(levelToPoll != null) {
if(mode != null ) {
mode.setLevelToPoll(levelToPoll);
}
}
}
}

if(component != null) {
mode.setComponent(component);
Expand Down Expand Up @@ -280,6 +280,8 @@ public boolean checkout(AbstractBuild<?, ?> build, Launcher launcher, FilePath w
build.setDescription("No valid baselines found");
throw new AbortException("No valid baselines found");
}
} catch (AbortException abex) {
throw abex;
} catch (IOException e) {
Exception cause = (Exception) e.getCause();
if (cause != null) {
Expand Down Expand Up @@ -597,8 +599,7 @@ private List<String> parseExclusionList(FilePath workspace, String exclude) thro
}
}

logger.finest("Done excluding");

logger.finest("Done excluding");
return excludes;
}

Expand Down Expand Up @@ -639,32 +640,80 @@ private void resolveBaseline(FilePath workspace, AbstractProject<?, ?> project,
} else if(_getPolling().isPollingOther()) {
baselines = getBaselinesFromStreams(workspace, listener, out, action.getStream(), action.getComponent(), _getPolling(), date);
} else {
PollRebaseMode md = (PollRebaseMode)mode;
PollRebaseMode md = (PollRebaseMode)mode;
List<String> parsedList = parseExclusionList(workspace, md.getExcludeList());
out.println("[" + Config.nameShort + "] Excluding the following components: ");

for(String exclude : parsedList) {
if(!StringUtils.isBlank(exclude)) {
out.println(String.format("%s * %s", "[" + Config.nameShort + "]", exclude));
}
}
Tuple<List<Baseline>,List<Baseline>> results = getBaselinesForPollRebase(workspace, listener, action.getStream(), parsedList);
baselines = results.t1;
action.setRebaseTargets(baselines);
action.setNewFoundationStructure(results.t2);
action.setNewFoundationStructure(results.t2);
}




/* if we did not find any baselines we should return false */
if (baselines.size() < 1) {
throw new CCUCMException("No valid Baselines found");
}


/* If the exlusion list contains invalid elements */


/* Select and load baseline */
action.setBaseline(selectBaseline(baselines, _getPlevel(), workspace));

/* Print the baselines to jenkins out */
printBaselines(baselines, out);
out.println("");

if(_getPolling().isPollingRebase()) {
PollRebaseMode md = (PollRebaseMode)mode;
List<String> parsedList = parseExclusionList(workspace, md.getExcludeList());
out.println("[" + Config.nameShort + "] Excluding the following components: ");

for(String exclude : parsedList) {
if(!StringUtils.isBlank(exclude)) {
out.println(String.format("%s * %s", "[" + Config.nameShort + "]", exclude));
}
}
checkExclusionList(listener, parsedList, workspace, action.getNewFoundationStructure());
}
}

private void checkExclusionList(BuildListener listener, List<String> exludeComponents, FilePath workspace, List<Baseline> baselines) throws AbortException {

List<String> missing = new ArrayList<String>();
for(String excl : exludeComponents) {
boolean wasThere = false;
for(Baseline foundabl : baselines) {
if(foundabl.getComponent().getNormalizedName().equals(excl)) {
wasThere = true;
}
}

if(!wasThere) {
missing.add(excl);
}

}

if(!missing.isEmpty()) {
listener.getLogger().println(String.format("%s Warning: Excluded component(s) %s not found.", "[" + Config.nameShort + "]", missing));
}

for(String s : exludeComponents) {
if(!StringUtils.isBlank(s)) {
if(!s.startsWith("component")) {
try {
RemoteUtil.loadEntity(workspace, Component.get(s), getSlavePolling());
} catch (Exception ex) {
throw new AbortException(String.format("Unable to load component %s", s));
}
}
}
}

}

/**
Expand Down
@@ -1,7 +1,7 @@
<?jelly escape-by-default='true'?>
<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">
<st:include page="config.jelly" class="net.praqma.hudson.scm.pollingmode.PollingMode"></st:include>
<f:entry title="Exlude components">
<f:entry title="Exlude components" description="Newline delimited list of components to exclude when polling, expand the box by clicking the arrow on the right side of the text box.">
<f:expandableTextbox field="excludeList">
</f:expandableTextbox>
</f:entry>
Expand Down

0 comments on commit 7c90c3e

Please sign in to comment.