Skip to content

Commit

Permalink
JENKINS-29033
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen committed Jun 23, 2015
1 parent b13856a commit 775c2d3
Show file tree
Hide file tree
Showing 37 changed files with 1,879 additions and 69 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -418,6 +418,12 @@
<artifactId>praqmajutils</artifactId>
<version>0.1.33</version>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>compatibility-action-storage</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/net/praqma/hudson/CCUCMBuildAction.java
Expand Up @@ -11,11 +11,13 @@
import net.praqma.clearcase.ucm.view.SnapshotView;
import net.praqma.hudson.scm.Polling;
import net.praqma.hudson.scm.Unstable;
import net.praqma.hudson.scm.pollingmode.PollingMode;

public class CCUCMBuildAction implements Action {

private AbstractBuild<?, ?> build;
private transient TaskListener listener;
private PollingMode mode;

private Stream stream;
private Component component;
Expand Down Expand Up @@ -354,7 +356,6 @@ public String toString() {
return stream + ", " + component + ", " + promotionLevel + " = " + baseline;
}


public String stringify() {
StringBuilder sb = new StringBuilder();
sb.append( "Stream : " + stream + "\n" );
Expand Down Expand Up @@ -388,5 +389,19 @@ public List<Baseline> getNewFoundationStructure() {
public void setNewFoundationStructure(List<Baseline> newFoundationStructure) {
this.newFoundationStructure = newFoundationStructure;
}

/**
* @return the mode
*/
public PollingMode getMode() {
return mode;
}

/**
* @param mode the mode to set
*/
public void setMode(PollingMode mode) {
this.mode = mode;
}

}
1 change: 0 additions & 1 deletion src/main/java/net/praqma/hudson/Config.java
Expand Up @@ -40,7 +40,6 @@ public static Stream devStream( String pvob ) throws ScmException {
public static Stream getIntegrationStream( Baseline bl, String buildProject ) throws ScmException {
Stream stream = null;
Project project = null;

/*
* If the build project was not given as a parameter to the job, try to
* find hudson, Hudson, jenkins or Jenkins
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/praqma/hudson/LoggerListener.java
@@ -1,6 +1,5 @@
package net.praqma.hudson;

import hudson.Extension;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.listeners.RunListener;
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/net/praqma/hudson/PromotionListAction.java
@@ -0,0 +1,24 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package net.praqma.hudson;

import hudson.model.InvisibleAction;
import java.util.List;
import net.praqma.clearcase.ucm.entities.Baseline;

/**
*
* @author Mads
*/
public class PromotionListAction extends InvisibleAction {

public final List<Baseline> baselines;

public PromotionListAction(List<Baseline> baselines) {
this.baselines = baselines;
}

}
29 changes: 7 additions & 22 deletions src/main/java/net/praqma/hudson/notifier/CCUCMNotifier.java
Expand Up @@ -9,7 +9,6 @@
import org.kohsuke.stapler.StaplerRequest;

import net.praqma.clearcase.ucm.entities.Baseline;
import net.praqma.clearcase.ucm.entities.Stream;
import net.praqma.clearcase.util.ExceptionUtils;
import net.praqma.hudson.CCUCMBuildAction;
import net.praqma.hudson.Config;
Expand All @@ -31,7 +30,6 @@
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import net.praqma.clearcase.Rebase;
import net.praqma.clearcase.ucm.entities.Component;
import net.praqma.hudson.exception.TemplateException;
import net.praqma.hudson.remoting.RebaseCancelTask;
Expand Down Expand Up @@ -96,7 +94,6 @@ public boolean perform( AbstractBuild<?, ?> build, Launcher launcher, BuildListe
if( baseline != null ) {
out.println( String.format ( "%s Processing baseline", "["+Config.nameShort + "]"));
status.setErrorMessage( action.getError() );

try {
processBuild( build, launcher, listener, action );
if( action.doSetDescription() ) {
Expand All @@ -108,7 +105,6 @@ public boolean perform( AbstractBuild<?, ?> build, Launcher launcher, BuildListe
logger.fine( String.format( "Setting build description to: %s", status.getBuildDescr() ) );
build.setDescription( status.getBuildDescr() );
}

}

} catch( NotifierException ne ) {
Expand Down Expand Up @@ -175,12 +171,6 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi

CCUCMBuildAction action = build.getAction( CCUCMBuildAction.class );

/* Initialize variables for post build steps */
Stream targetstream = null;
targetstream = pstate.getBaseline().getStream();
Stream sourcestream = targetstream;
Baseline sourcebaseline = pstate.getBaseline();
Baseline targetbaseline = sourcebaseline;
logger.fine(String.format("NTBC: %s",pstate.doNeedsToBeCompleted()));

/*
Expand Down Expand Up @@ -208,8 +198,8 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
if( treatSuccessful && pstate.doCreateBaseline() ) {

try {
targetbaseline = createBaselineOnSuccess(workspace, pstate, build, currentWorkspace, pstate.getBaseline().getComponent());
action.setCreatedBaseline( targetbaseline );
Baseline succesBaseline = createBaselineOnSuccess(workspace, pstate, build, currentWorkspace, pstate.getBaseline().getComponent());
action.setCreatedBaseline( succesBaseline );

} catch( Exception e ) {
ExceptionUtils.print( e, out, false );
Expand Down Expand Up @@ -260,9 +250,6 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
}
}
}
if( pstate.getPolling().isPollingOther() || pstate.getPolling().isPollingRebase() ) {
targetstream = pstate.getStream();
}

//Complete the rebase
try {
Expand All @@ -276,8 +263,8 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
pstate.setWorkspace( workspace );
NameTemplate.validateTemplates( pstate, build.getWorkspace() );
String name = NameTemplate.parseTemplate( pstate.getNameTemplate(), pstate, build.getWorkspace() );
targetbaseline = RemoteUtil.createRemoteBaseline( currentWorkspace, name, pstate.getStream(), pstate.getViewPath() );
action.setCreatedBaseline( targetbaseline );
Baseline createdRebaseBaseline = RemoteUtil.createRemoteBaseline( currentWorkspace, name, pstate.getStream(), pstate.getViewPath() );
action.setCreatedBaseline( createdRebaseBaseline );
}

} else if ( !treatSuccessful && pstate.getPolling().isPollingRebase()) {
Expand All @@ -303,15 +290,13 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
logger.fine( String.format( "Remote post build step" ) );
out.println( String.format( "%s Performing common post build steps",logShortPrefix ) );

//Do not promote source when polling rebase.
boolean skipPromote = pstate.getPromotionLevel() == null || pstate.getPolling().isPollingRebase();
status = currentWorkspace.act( new RemotePostBuild( buildResult, status, listener, pstate.doMakeTag(), pstate.doRecommend(), pstate.getUnstable(), skipPromote, sourcebaseline, targetbaseline, sourcestream, targetstream, build.getParent().getDisplayName(), Integer.toString( build.getNumber() ), pstate.getRebaseTargets() ) );
status = currentWorkspace.act(pstate.getMode().postBuildFinalizer(build, listener, status));
//status = currentWorkspace.act( new RemotePostBuild( buildResult, status, listener, pstate.doMakeTag(), pstate.doRecommend(), pstate.getUnstable(), skipPromote, sourcebaseline, targetbaseline, sourcestream, targetstream, build.getParent().getDisplayName(), Integer.toString( build.getNumber() ), pstate.getRebaseTargets() ) );
} catch( Exception e ) {
status.setStable( false );
logger.log( Level.WARNING, "", e );
out.println( String.format( "%s Error: Post build failed", logShortPrefix ) );
Throwable cause = net.praqma.util.ExceptionUtils.unpackFrom( IOException.class, e );

ExceptionUtils.print( cause, out, true );
}

Expand Down Expand Up @@ -340,7 +325,7 @@ private Baseline createBaselineOnSuccess(String workspace, CCUCMBuildAction psta
targetbaseline = RemoteUtil.createRemoteBaseline( currentWorkspace, name, component, pstate.getViewPath() );
return targetbaseline;
}

/**
* This class is used by Hudson to define the plugin.
*
Expand Down
@@ -0,0 +1,14 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package net.praqma.hudson.notifier;

/**
*
* @author Mads
*/
public class PollOthersRemotePostBuild {

}

0 comments on commit 775c2d3

Please sign in to comment.