Skip to content
Permalink
Browse files
Fixing JENKINS-23533
  • Loading branch information
MadsNielsen committed Nov 4, 2014
1 parent bca45f1 commit a20a816b2100c273c8aa1aa6a2152d4c6aaddc6f
@@ -430,14 +430,14 @@
<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.31</version>
<version>0.6.35</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.31</version>
<version>0.6.35</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
@@ -353,7 +353,7 @@ public String toString() {


public String stringify() {
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
sb.append( "Stream : " + stream + "\n" );
sb.append( "Component : " + component + "\n" );
sb.append( "Promotion Level : " + promotionLevel + "\n" );
@@ -62,31 +62,36 @@ public Stream getDeveloperStream( String streamname, PVob pvob, Stream buildInte
return devstream;
}

public static String createChangelog(AbstractBuild<?, ?> build, List<Activity> activities, Baseline bl, boolean trimmed, File viewRoot, List<String> readonly ) throws IOException, InterruptedException {
public static String createChangelog(AbstractBuild<?, ?> build, List<Activity> activities, Baseline bl, boolean trimmed, File viewRoot, List<String> readonly, boolean ignoreReadOnly ) throws IOException, InterruptedException {
logger.fine( String.format("Trim changeset: %s", trimmed));
ChangeSetGenerator csg = new ChangeSetGenerator().createHeader( bl.getShortname() );

if( trimmed ) {
logger.fine("Creating trimmed change set");
VersionList vl = new VersionList().addActivities( activities ).setBranchName( "^.*" + Cool.qfs + bl.getStream().getShortname() + ".*$" );
logger.fine("Versions before filter: " + vl.size());

if(ignoreReadOnly) {
vl = vl.addFilter(new ReadOnlyVersionFilter(viewRoot, readonly)).apply();
}

Map<Activity, List<Version>> changeSet = build.getWorkspace().act(new GetLatestForActivities(vl));
int now = 0;

for(List<Version> vlist : changeSet.values()) {
now+=vlist.size();
}

logger.fine("Versions after filter: " + now);

for( Activity activity : changeSet.keySet() ) {
csg.addAcitivity( activity.getShortname(), activity.getHeadline(), activity.getUser(), changeSet.get( activity ) );
}
} else {
logger.fine("Creating non-trimmed changeset");
for( Activity activity : activities ) {
VersionList versions = new VersionList( activity.changeset.versions ).getLatest();
if(ignoreReadOnly) {
versions = versions.addFilter(new ReadOnlyVersionFilter(viewRoot, readonly)).apply();
}

csg.addAcitivity( activity.getShortname(), activity.getHeadline(), activity.getUser(), versions );
}
}
@@ -139,11 +144,11 @@ public String get() {
return buffer.toString();
}
}

/*
public static SnapshotView makeView( Stream stream, File workspace, BuildListener listener, String loadModule, File viewroot, String viewtag ) throws ScmException {
return makeView( stream, workspace, listener, loadModule, viewroot, viewtag, true );
}

*/
public static SnapshotView makeView( Stream stream, File workspace, BuildListener listener, String loadModule, File viewroot, String viewtag, boolean update ) throws ScmException {

PrintStream hudsonOut = listener.getLogger();
@@ -189,7 +194,7 @@ public static SnapshotView makeView( Stream stream, File workspace, BuildListene
} catch( Exception e ) {
throw new ScmException( "Unable to recursively prepare view root", e );
}
makeView( stream, workspace, listener, loadModule, viewroot, viewtag );
makeView( stream, workspace, listener, loadModule, viewroot, viewtag, true );
}
} catch( ClearCaseException ucmE ) {
try {
@@ -234,8 +239,7 @@ public static SnapshotView makeView( Stream stream, File workspace, BuildListene
try {
hudsonOut.println( "[" + Config.nameShort + "] Updating view using " + loadModule.toLowerCase() + " modules." );
UpdateView uw = new UpdateView(snapview).swipe().generate().overwrite().setLoadRules(new LoadRules2( snapview, Components.valueOf( loadModule.toUpperCase() ) ));
uw.update();
//snapview.Update( true, true, true, false, new LoadRules2( snapview, Components.valueOf( loadModule.toUpperCase() ) ) );
uw.update();
} catch( ClearCaseException e ) {
e.print( hudsonOut );
if( e instanceof ViewException ) {
@@ -192,7 +192,7 @@ private void makeWorkspace(File workspace, String viewtag) throws ScmException,

upview.setLoadRules(new LoadRules2(sv, Components.valueOf(loadModule.toUpperCase())));
//sv.Update(swipe, true, true, false, new LoadRules2(sv, Components.valueOf(loadModule.toUpperCase())));
upview.update();
upview.update();
logger.fine("Updating done");
} catch (ClearCaseException e) {
e.print(hudsonOut);
@@ -11,7 +11,6 @@
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.praqma.clearcase.exceptions.UnableToLoadEntityException;
import net.praqma.clearcase.ucm.entities.Activity;
@@ -46,10 +46,8 @@ public Boolean invoke( File f, VirtualChannel channel ) throws IOException, Inte

Deliver deliver = new Deliver( baseline, baseline.getStream(), stream, viewPath, viewtag );
if( complete ) {

try {
deliver.complete();
//baseline.deliver( baseline.getStream(), stream, view.getViewRoot(), view.getViewtag(), true, true, true );
} catch( Exception ex ) {
try {
deliver.cancel();
@@ -61,8 +59,7 @@ public Boolean invoke( File f, VirtualChannel channel ) throws IOException, Inte

} else {
out.println( "Cancelling" );
try {
//baseline.cancel( view.getViewRoot() );
try {
deliver.cancel();
} catch( Exception ex ) {
throw new IOException( "Could not cancel the deliver.", ex );
@@ -46,9 +46,8 @@ public SnapshotView invoke( File workspace, VirtualChannel channel ) throws IOEx

private SnapshotView makeDeliverView( Stream stream, File workspace ) throws ScmException {
viewtag = Util.createViewTag( jobName, stream );

File viewroot = new File( workspace, "view" );

return Util.makeView( stream, workspace, listener, loadModule, viewroot, viewtag );
SnapshotView view = Util.makeView( stream, workspace, listener, loadModule, viewroot, viewtag, true );
return view;
}
}
@@ -135,7 +135,7 @@ public CCUCMScm(String component, String levelToPoll, String loadModule, boolean
this.setDescription = setDescription;
this.plevel = Util.getLevel(levelToPoll);
this.levelToPoll = levelToPoll;
this.discard = false;
this.discard = discard;
}

@Override
@@ -407,11 +407,12 @@ private boolean checkInput(TaskListener listener) {
private boolean initializeWorkspace(AbstractBuild<?, ?> build, FilePath workspace, File changelogFile, BuildListener listener, CCUCMBuildAction action) throws IOException, InterruptedException {
PrintStream consoleOutput = listener.getLogger();
EstablishResult er = null;

CheckoutTask ct = new CheckoutTask(listener, jobName, build.getNumber(), action.getStream(), loadModule, action.getBaseline(), buildProject, (plevel == null), action.doRemoveViewPrivateFiles());
er = workspace.act(ct);
//String changelog = er.getMessage();

String changelog = "";
changelog = Util.createChangelog(build, er.getActivities(), action.getBaseline(), trimmedChangeSet, er.getView().getViewRoot(), er.getView().getReadOnlyLoadLines());
changelog = Util.createChangelog(build, er.getActivities(), action.getBaseline(), trimmedChangeSet, er.getView().getViewRoot(), er.getView().getReadOnlyLoadLines(), discard);
action.setActivities(er.getActivities());

this.viewtag = er.getViewtag();
@@ -535,6 +536,7 @@ public SnapshotView initializeDeliverView(AbstractBuild<?, ?> build, CCUCMBuildA
state.setViewPath(view.getViewRoot());
state.setViewTag(view.getViewtag());
state.setSnapshotView(view);

this.viewtag = view.getViewtag();

return view;
@@ -562,7 +564,7 @@ public void generateChangeLog(AbstractBuild<?, ?> build, CCUCMBuildAction state,

String changelog = "";

changelog = Util.createChangelog(build, activities, state.getBaseline(), trimmedChangeSet, new File(snapshotView.getPath()), snapshotView.getReadOnlyLoadLines());
changelog = Util.createChangelog(build, activities, state.getBaseline(), trimmedChangeSet, new File(snapshotView.getPath()), snapshotView.getReadOnlyLoadLines(), discard);
state.setActivities(activities);

/* Write change log */
@@ -1,6 +1,5 @@
<?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">
<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}"/>
@@ -16,7 +15,7 @@
<j:forEach var="l" items="${levels}">
<f:option selected="${scm.levelToPoll==l}" value="${l}">${l}</f:option>
</j:forEach>
</select>
</select>
</f:entry>

<f:entry title="Load modules" help="/plugin/clearcase-ucm-plugin/scm/help-loadModules.html">
@@ -28,15 +27,13 @@
</select>
</f:entry>

<f:entry title="Polling" help="/plugin/clearcase-ucm-plugin/scm/help-polling.html">
<select class="setting-input" name="CCUCM.polling" checkUrl="'${rootURL}/scm/CCUCMScm/levelCheck?polling='+encodeURIComponent(this.value)+'&amp;level='+encodeURIComponent(Form.findMatchingInput(this,'CCUCM.levelToPoll').value)">
<f:option selected="${instance.polling == 'self'}" value="self">Poll self</f:option>
<f:option selected="${instance.polling == 'childs'}" value="child">Poll child streams</f:option>
<f:option selected="${instance.polling == 'siblings'}" value="sibling">Poll sibling streams</f:option>
</select>
</f:entry>

<!-- unstable -->
<f:entry title="Polling" help="/plugin/clearcase-ucm-plugin/scm/help-polling.html">
<select class="setting-input" name="CCUCM.polling" checkUrl="'${rootURL}/scm/CCUCMScm/levelCheck?polling='+encodeURIComponent(this.value)+'&amp;level='+encodeURIComponent(Form.findMatchingInput(this,'CCUCM.levelToPoll').value)">
<f:option selected="${instance.polling == 'self'}" value="self">Poll self</f:option>
<f:option selected="${instance.polling == 'childs'}" value="child">Poll child streams</f:option>
<f:option selected="${instance.polling == 'siblings'}" value="sibling">Poll sibling streams</f:option>
</select>
</f:entry>

<f:entry title="Create baseline" help="/plugin/clearcase-ucm-plugin/scm/help-createBaseline.html">
<f:checkbox name="CCUCM.createBaseline" checked="${scm.createBaseline}" checkUrl="'${rootURL}/scm/CCUCMScm/checkMode?checked='+(this.checked)+'&amp;mode='+encodeURIComponent(Form.findMatchingInput(this,'CCUCM.polling').value)" />
@@ -46,8 +43,6 @@
<f:textbox name="CCUCM.nameTemplate" value="${scm.nameTemplate}" default="[project]_[date]_[time]" />
</f:entry>

<!-- Force deliver -->

<f:entry title="Recommend baseline" help="/plugin/clearcase-ucm-plugin/scm/help-recommendBaseline.html">
<f:checkbox name="CCUCM.recommend" checked="${scm.recommend}" />
</f:entry>
@@ -59,34 +54,39 @@
<f:entry title="Set description" help="/plugin/clearcase-ucm-plugin/scm/help-setDescription.html">
<f:checkbox name="CCUCM.setDescription" checked="${h.defaultToTrue(scm.setDescription)}" default="checked" />
</f:entry>
<f:section title="Advanced ClearCase UCM Options">
<f:advanced>

<f:entry title="Unstable" help="/plugin/clearcase-ucm-plugin/scm/help-unstable.html">
<select class="setting-input" name="CCUCM.treatUnstable">
<f:option selected="${instance.treatUnstable == 'successful'}" value="successful">Unstable jobs are treated as successful</f:option>
<f:option selected="${instance.treatUnstable == 'failed'}" value="failed">Unstable jobs are treated as failed</f:option>
</select>
</f:entry>

<f:entry title="Force deliver" help="/plugin/clearcase-ucm-plugin/scm/help-forceDeliver.html">
<f:checkbox name="CCUCM.forceDeliver" checked="${scm.forceDeliver}" />
</f:entry>

<f:entry title="Remove view private files" help="/plugin/clearcase-ucm-plugin/scm/help-removeViewPrivateFiles.html">
<f:checkbox name="CCUCM.removeViewPrivateFiles" checked="${scm.removeViewPrivateFiles}" default="true"/>
</f:entry>

<f:entry title="Trimmed change set" help="/plugin/clearcase-ucm-plugin/scm/help-trimmedChangeSet.html">
<f:checkbox name="CCUCM.trimmedChangeSet" checked="${scm.trimmedChangeSet}" default="false" />
</f:entry>

<f:entry title="Build project" help="/plugin/clearcase-ucm-plugin/scm/help-buildProject.html">
<f:textbox name="buildProject" value="${scm.buildProject}"/>
</f:entry>

</f:advanced>

</f:section>

<f:section title="Advanced ClearCase UCM Options">
<f:advanced>

<f:entry title="Unstable" help="/plugin/clearcase-ucm-plugin/scm/help-unstable.html">
<select class="setting-input" name="CCUCM.treatUnstable">
<f:option selected="${instance.treatUnstable == 'successful'}" value="successful">Unstable jobs are treated as successful</f:option>
<f:option selected="${instance.treatUnstable == 'failed'}" value="failed">Unstable jobs are treated as failed</f:option>
</select>
</f:entry>

<f:entry title="Force deliver" help="/plugin/clearcase-ucm-plugin/scm/help-forceDeliver.html">
<f:checkbox name="CCUCM.forceDeliver" checked="${scm.forceDeliver}" />
</f:entry>

<f:entry title="Remove view private files" help="/plugin/clearcase-ucm-plugin/scm/help-removeViewPrivateFiles.html">
<f:checkbox name="CCUCM.removeViewPrivateFiles" checked="${scm.removeViewPrivateFiles}" default="true"/>
</f:entry>

<f:entry title="Trimmed change set" help="/plugin/clearcase-ucm-plugin/scm/help-trimmedChangeSet.html">
<f:checkbox name="CCUCM.trimmedChangeSet" checked="${scm.trimmedChangeSet}" default="false" />
</f:entry>

<f:entry title="Ignore changes under non-modifiable components when calculating change-set" field="discard">
<f:checkbox checked="${scm.discard}" default="false" />
</f:entry>

<f:entry title="Build project" help="/plugin/clearcase-ucm-plugin/scm/help-buildProject.html">
<f:textbox name="buildProject" value="${scm.buildProject}"/>
</f:entry>

</f:advanced>

</f:section>

</j:jelly>

0 comments on commit a20a816

Please sign in to comment.