Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixing JENKINS-25059
  • Loading branch information
MadsNielsen committed Oct 9, 2014
1 parent 725f99b commit bca45f1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/main/java/net/praqma/hudson/Util.java
@@ -1,6 +1,7 @@
package net.praqma.hudson;

import hudson.FilePath;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;

import java.io.*;
Expand Down Expand Up @@ -28,6 +29,7 @@
import net.praqma.clearcase.ucm.view.SnapshotView.LoadRules2;
import net.praqma.clearcase.ucm.view.UpdateView;
import net.praqma.hudson.exception.ScmException;
import net.praqma.hudson.remoting.GetLatestForActivities;
import org.apache.commons.lang.SystemUtils;

public abstract class Util {
Expand Down Expand Up @@ -60,7 +62,7 @@ public Stream getDeveloperStream( String streamname, PVob pvob, Stream buildInte
return devstream;
}

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

Expand All @@ -69,7 +71,7 @@ public static String createChangelog( List<Activity> activities, Baseline bl, bo
VersionList vl = new VersionList().addActivities( activities ).setBranchName( "^.*" + Cool.qfs + bl.getStream().getShortname() + ".*$" );
logger.fine("Versions before filter: " + vl.size());

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

for(List<Version> vlist : changeSet.values()) {
Expand Down
@@ -0,0 +1,61 @@
/*
* 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.remoting;

import hudson.FilePath;
import hudson.remoting.VirtualChannel;
import java.io.File;
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;
import net.praqma.clearcase.ucm.entities.Version;
import net.praqma.clearcase.ucm.utils.VersionList;

/**
*
* @author Mads
*/
public class GetLatestForActivities implements FilePath.FileCallable<Map<Activity, List<Version>>> {

private static final Logger LOG = Logger.getLogger(GetLatestForActivities.class.getName());
private VersionList list;

public GetLatestForActivities(VersionList list) {
this.list = list;
}

@Override
public Map<Activity, List<Version>> invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
Map<Activity, List<Version>> activities = list.getLatestForActivities();
for(Activity a : activities.keySet()) {
try {
a.load();
} catch (UnableToLoadEntityException ex) {
LOG.severe("Could not autoload actitity "+a);
}
}
return activities;
}

/**
* @return the list
*/
public VersionList getList() {
return list;
}

/**
* @param list the list to set
*/
public void setList(VersionList list) {
this.list = list;
}

}
10 changes: 8 additions & 2 deletions src/main/java/net/praqma/hudson/scm/CCUCMScm.java
Expand Up @@ -411,7 +411,7 @@ private boolean initializeWorkspace(AbstractBuild<?, ?> build, FilePath workspac
er = workspace.act(ct);
//String changelog = er.getMessage();
String changelog = "";
changelog = Util.createChangelog(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());
action.setActivities(er.getActivities());

this.viewtag = er.getViewtag();
Expand Down Expand Up @@ -543,6 +543,11 @@ public SnapshotView initializeDeliverView(AbstractBuild<?, ?> build, CCUCMBuildA
/**
* Generate the change log for poll/sibling mode
* @param build
* @param state
* @param listener
* @param changelogFile
* @param snapshotView
* @throws java.io.IOException
* @throws java.lang.InterruptedException
*/
public void generateChangeLog(AbstractBuild<?, ?> build, CCUCMBuildAction state, BuildListener listener, File changelogFile, SnapshotView snapshotView) throws IOException, InterruptedException {
Expand All @@ -556,7 +561,8 @@ public void generateChangeLog(AbstractBuild<?, ?> build, CCUCMBuildAction state,
List<Activity> activities = workspace.act(gc);

String changelog = "";
changelog = Util.createChangelog(activities, state.getBaseline(), trimmedChangeSet, new File(snapshotView.getPath()), snapshotView.getReadOnlyLoadLines());

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

/* Write change log */
Expand Down

0 comments on commit bca45f1

Please sign in to comment.