Skip to content

Commit

Permalink
Merge pull request #22 from MadsNielsen/JENKINS-28835
Browse files Browse the repository at this point in the history
Jenkins 28835
  • Loading branch information
MadsNielsen committed Jun 15, 2015
2 parents b13856a + 17b35c4 commit 7ec2a7c
Show file tree
Hide file tree
Showing 21 changed files with 165 additions and 48 deletions.
10 changes: 5 additions & 5 deletions pom.xml
Expand Up @@ -416,32 +416,32 @@
<dependency>
<groupId>net.praqma</groupId>
<artifactId>praqmajutils</artifactId>
<version>0.1.33</version>
<version>0.1.35</version>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
<artifactId>praqmajutils</artifactId>
<version>0.1.33</version>
<version>0.1.35</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.39</version>
<version>0.6.40</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.39</version>
<version>0.6.40</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Expand Up @@ -276,7 +276,7 @@ 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() );
targetbaseline = RemoteUtil.createRemoteBaseline( currentWorkspace, name, pstate.getStream(), pstate.getComponent(), pstate.getViewPath() );
action.setCreatedBaseline( targetbaseline );
}

Expand Down
Expand Up @@ -26,9 +26,9 @@ public CreateRemoteBaseline( String baseName, Component component, File view ) {
this.stream = null;
}

public CreateRemoteBaseline( String baseName, Stream stream, File view ) {
public CreateRemoteBaseline( String baseName, Stream stream, Component component, File view ) {
this.baseName = baseName;
this.component = null;
this.component = component;
this.view = view;
this.stream = stream;
}
Expand All @@ -38,10 +38,10 @@ public Baseline invoke( File f, VirtualChannel channel ) throws IOException, Int

Baseline bl = null;
try {
if(component != null) {
if(stream == null) {
bl = Baseline.create( baseName, component, view, LabelBehaviour.INCREMENTAL, false );
} else {
bl = Baseline.create(stream, baseName, view, LabelBehaviour.INCREMENTAL, false);
bl = Baseline.create(stream, component, baseName, view, LabelBehaviour.INCREMENTAL, false);
}
} catch( Exception e ) {
throw new IOException( "Unable to create Baseline:" + e.getMessage(), e );
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/praqma/hudson/remoting/RemoteUtil.java
Expand Up @@ -37,8 +37,8 @@ public static Baseline createRemoteBaseline( FilePath workspace, String baseName
return workspace.act( new CreateRemoteBaseline( baseName, component, view ) );
}

public static Baseline createRemoteBaseline( FilePath workspace, String baseName, Stream stream, File view ) throws IOException, InterruptedException {
return workspace.act( new CreateRemoteBaseline( baseName, stream, view ) );
public static Baseline createRemoteBaseline( FilePath workspace, String baseName, Stream stream, Component component, File view ) throws IOException, InterruptedException {
return workspace.act( new CreateRemoteBaseline( baseName, stream, component, view ) );
}

public static UCMEntity loadEntity( FilePath workspace, UCMEntity entity, boolean slavePolling ) throws IOException, InterruptedException {
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/net/praqma/hudson/scm/CCUCMScm.java
Expand Up @@ -1208,6 +1208,13 @@ public void setMode(PollingMode mode) {
this.mode = mode;
}

/**
* @param stream the stream to set
*/
public void setStream(String stream) {
this.stream = stream;
}

/**
* This class is used to describe the plugin to Hudson
*
Expand Down Expand Up @@ -1275,6 +1282,7 @@ public boolean getMultisitePolling() {

/**
* This is called by Hudson to discover the plugin name
* @return The name to be displayed when the user selects the SCM
*/
@Override
public String getDisplayName() {
Expand All @@ -1299,9 +1307,20 @@ public FormValidation doCheckTemplate(@QueryParameter String value) throws FormV
} catch (TemplateException e) {
throw FormValidation.error("Does not appear to be a valid template: " + e.getMessage());
}

}


public FormValidation doCheckStream(@QueryParameter String stream) {
if(StringUtils.isBlank(stream)) {
return FormValidation.error("Stream field cannot be empty");
} else {
if(!stream.contains("@\\")) {
return FormValidation.errorWithMarkup("Streams must be defined with the correct syntax. <em>Syntax: [stream]@[vob]</em>");
}
}
return FormValidation.ok();
}

@Override
public CCUCMScm newInstance(StaplerRequest req, JSONObject formData) throws Descriptor.FormException {
CCUCMScm temp;
Expand Down
Expand Up @@ -6,7 +6,10 @@
package net.praqma.hudson.scm.pollingmode;

import hudson.model.Descriptor;
import hudson.util.FormValidation;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

/**
Expand All @@ -21,4 +24,14 @@ public PollingMode newInstance(StaplerRequest req, JSONObject formData) throws F
return req.bindJSON(PollingMode.class, formData);
}

public FormValidation doCheckComponent(@QueryParameter String component) {
if(StringUtils.isBlank(component)) {
return FormValidation.error("Component field cannot be empty");
} else {
if(!component.contains("@\\")) {
return FormValidation.errorWithMarkup("Components must be entered with the correct syntax. <em>Syntax: [component]@[PVOB]</em>");
}
}
return FormValidation.ok();
}
}
@@ -1,8 +1,8 @@
<?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">

<f:entry title="Stream" help="/plugin/clearcase-ucm-plugin/scm/help-stream.html">
<f:textbox name="CCUCM.stream" value="${scm.stream}"/>
<f:entry title="Stream" field="stream">
<f:textbox/>
</f:entry>

<f:entry title="Load modules" help="/plugin/clearcase-ucm-plugin/scm/help-loadModules.html">
Expand Down
@@ -0,0 +1,3 @@
<div>
Specify the stream you want to poll for with ClearCase UCM SCM. Syntax: [stream]@[PVOB]
</div>
@@ -1,10 +1,14 @@
<?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 field="component" title="Component">
<f:textbox/>
</f:entry>
<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>

<f:entry field="createBaseline" title="Create baseline">
<f:checkbox/>
</f:entry>
Expand Down
@@ -0,0 +1,5 @@
<div>
The component used to figure out the correct baseline to recommend due to the following bug:
<br/>
<a href="http://www-01.ibm.com/support/docview.wss?uid=swg21269043">http://www-01.ibm.com/support/docview.wss?uid=swg21269043</a>
</div>
3 changes: 0 additions & 3 deletions src/main/webapp/scm/help-stream.html

This file was deleted.

5 changes: 4 additions & 1 deletion src/test/java/net/praqma/hudson/test/BaseTestClass.java
Expand Up @@ -26,7 +26,10 @@ public class BaseTestClass {

@ClassRule
public static LoggingRule lrule = new LoggingRule( "net.praqma" );


@ClassRule
public static LoggerRule loggerRule = new LoggerRule();


@Before
public void before() {
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/net/praqma/hudson/test/CCUCMRule.java
Expand Up @@ -362,7 +362,7 @@ public boolean perform( AbstractBuild<?, ?> build, Launcher launcher, BuildListe

AbstractBuild<?,?> build = null;
try {
build = project.scheduleBuild2(1, new Cause.UserIdCause(), action ).get();
build = project.scheduleBuild2(0, new Cause.UserIdCause(), action ).get();
} catch( Exception e ) {
if(!fail) {
logger.log(Level.SEVERE, "Build failed...it should not!", e);
Expand All @@ -371,7 +371,6 @@ public boolean perform( AbstractBuild<?, ?> build, Launcher launcher, BuildListe
logger.info( "Build failed, and it should!");
}

waitUntilNoActivityUpTo(120000);

PrintStream out = new PrintStream( new File( outputDir, "jenkins." + getSafeName( project.getDisplayName() ) + "." + build.getNumber() + ".log" ) );

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/net/praqma/hudson/test/LoggerRule.java
Expand Up @@ -13,15 +13,15 @@ public class LoggerRule extends ExternalResource {

@Override
protected void before() {
System.out.println( " ==== Setting up logger" );
System.out.println( "[LoggerRule] Setting up logger" );
appender = new ConsoleAppender();
Logger.addAppender( appender );
Logger.setMinLogLevel( LogLevel.DEBUG );
}

@Override
protected void after() {
System.out.println( " ==== Removing " + appender );
System.out.println( "[LoggerRule] Removing " + appender );
Logger.removeAppender( appender );
}
}
Expand Up @@ -20,18 +20,14 @@
import net.praqma.hudson.test.LoggerRule;
import net.praqma.hudson.test.SystemValidator;
import net.praqma.util.test.junit.TestDescription;
import net.praqma.util.debug.Logger;

import net.praqma.clearcase.test.annotations.ClearCaseUniqueVobName;
import net.praqma.clearcase.test.junit.ClearCaseRule;
import net.praqma.hudson.scm.pollingmode.PollChildMode;


public class GetBaselinesTest extends BaseTestClass {

@ClassRule
public static LoggerRule loggerRule = new LoggerRule();


@Rule
public ClearCaseRule ccenv = new ClearCaseRule( "ccucm-child-getbaselines" );

Expand Down
Expand Up @@ -8,7 +8,6 @@
import hudson.model.AbstractBuild;
import hudson.model.Result;
import java.io.File;
import java.util.List;
import java.util.logging.Logger;
import net.praqma.clearcase.exceptions.ClearCaseException;
import net.praqma.clearcase.ucm.entities.Baseline;
Expand All @@ -30,14 +29,14 @@ public class BaselinesFound extends BaseTestClass {

private static final Logger logger = Logger.getLogger(BaselinesFound.class.getName());


@Rule
public ClearCaseRule ccenv = new ClearCaseRule("ccucm", "setup-interproject.xml" );
@Rule
public DescriptionRule desc = new DescriptionRule();

public AbstractBuild<?, ?> initiateBuild(String projectName, boolean recommend, boolean tag, boolean description, boolean fail, boolean mkbl) throws Exception {
PollRebaseMode mode = new PollRebaseMode("INITIAL");
mode.setComponent("_System@" + ccenv.getPVob());
mode.setCreateBaseline(mkbl);
return jenkins.initiateBuild(projectName, mode, "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), recommend, tag, description, fail, true);
}
Expand Down Expand Up @@ -87,6 +86,22 @@ public void testBasicMkBl() throws Exception {
.validate();
}

@Test
@ClearCaseUniqueVobName(name = "rebase-mkbl-rec")
@TestDescription(title = "Rebase polling, succes, recommend", text = "rebase baseline available, create a baseline")
public void testBasicMkBlRecommend() throws Exception {
Baseline baseline = getNewBaseline();

AbstractBuild<?, ?> build = initiateBuild("rebase-mkbl-rec" + ccenv.getUniqueName(), true, false, false, false, true);
SystemValidator validator = new SystemValidator(build)
.validateBuild(Result.SUCCESS)
.validateBuildView()
.validateCreatedBaseline(true, true)
.validateBuiltBaselineIsInFoundation(true)
.validateBuiltBaseline(PromotionLevel.INITIAL, baseline, false)
.validate();
}

protected Baseline getNewBaseline() throws ClearCaseException {
/**/
String viewtag = ccenv.getUniqueName() + "_bootstrap_int";
Expand Down
Expand Up @@ -3,33 +3,35 @@
import net.praqma.clearcase.test.annotations.ClearCaseUniqueVobName;
import net.praqma.clearcase.ucm.entities.Stream;
import net.praqma.util.test.junit.TestDescription;
import org.junit.Ignore;
import org.junit.Test;

public class Story06 extends Story06Base {



@Test
@ClearCaseUniqueVobName(name = "dip1")
@TestDescription(title = "Story 6", text = "New baseline on dev stream. Deliver in progress from another stream, different view", configurations = {"Force deliver = true", "Poll childs"})
@ClearCaseUniqueVobName(name = "dip1-noslave")
@TestDescription(title = "Story 6", text = "New baseline on dev stream. Deliver in progress from another stream, different view", configurations = {"Force deliver = true", "Poll childs", "Slave = false"})
public void story06_1() throws Exception {
Stream dev1 = ccenv.context.streams.get("one_dev");
Stream dev2 = ccenv.context.streams.get("two_dev");
runWithSlave(dev1, dev2, ccenv.getUniqueName() + "_one_dev", ccenv.getUniqueName() + "_two_dev", false);
run(dev1, dev2, ccenv.getUniqueName() + "_one_dev", ccenv.getUniqueName() + "_two_dev", false);
}

@Test
@ClearCaseUniqueVobName(name = "dip2")
@TestDescription(title = "Story 6", text = "New baseline on dev stream. Deliver in progress from same stream, different view", configurations = {"Force deliver = true", "Poll childs"})
@ClearCaseUniqueVobName(name = "dip2-noslave")
@TestDescription(title = "Story 6", text = "New baseline on dev stream. Deliver in progress from same stream, different view", configurations = {"Force deliver = true", "Poll childs", "Slave = false"})
public void story06_2() throws Exception {
Stream dev1 = ccenv.context.streams.get("one_dev");
runWithSlave(dev1, dev1, ccenv.getUniqueName() + "_one_dev", ccenv.getUniqueName() + "_one_dev", false);
run(dev1, dev1, ccenv.getUniqueName() + "_one_dev", ccenv.getUniqueName() + "_one_dev", false);
}

//TODO: This, for some reason starts to randomly fail when upgrading from 1.532.3 -> 1.554.3
@Test
@ClearCaseUniqueVobName(name = "dip3")
@TestDescription(title = "Story 6", text = "New baseline on dev stream. Deliver in progress from previous build, different view", configurations = {"Force deliver = true", "Poll childs"})
@Ignore
@ClearCaseUniqueVobName(name = "dip3-noslave")
@TestDescription(title = "Story 6", text = "New baseline on dev stream. Deliver in progress from previous build, different view", configurations = {"Force deliver = true", "Poll childs", "Slave = false"})
public void story06_3() throws Exception {
Stream dev1 = ccenv.context.streams.get("one_dev");
runWithSlave(null, dev1, null, ccenv.getUniqueName() + "_one_dev", true);
run(null, dev1, null, ccenv.getUniqueName() + "_one_dev", true);
}
}
Expand Up @@ -33,8 +33,10 @@ public abstract class Story06Base extends BaseTestClass {

@Rule
public ClearCaseRule ccenv = new ClearCaseRule("ccucm-story06", "setup-story5.xml");

@Rule
public DescriptionRule desc = new DescriptionRule();

private static final Logger logger = Logger.getLogger(Story06Base.class.getName());

/**
Expand Down Expand Up @@ -66,6 +68,7 @@ public void runWithSlave(Stream stream1, Stream streamToMakeAnotherBaseline, Str
//project.getBuildersList().add( builder );
project.getPublishersList().remove(CCUCMNotifier.class);
((CCUCMScm) project.getScm()).setAddPostBuild(false);
project.save();
}

AbstractBuild<?, ?> firstbuild = jenkins.buildProject(project, false);
Expand Down

0 comments on commit 7ec2a7c

Please sign in to comment.