if (stream == null || "".equals(stream)) {
listener.fatalError("Must specify a stream");
return false;
}
final EnvVars environment = build.getEnvironment(listener);
environment.put("ACCUREV_CLIENT_PATH", accurevClientExePath);
String localStream = environment.expand(stream);
listener.getLogger().println("Getting a list of streams...");
final Map<String, AccurevStream> streams = ShowStreams.getStreams(this, localStream, server, accurevEnv, jenkinsWorkspace, listener, accurevClientExePath,
launcher);
if (streams != null && !streams.containsKey(localStream)) {
listener.fatalError("The specified stream, '" + localStream + "' does not appear to exist!");
return false;
}
if (useReftree && (this.reftree == null || "".equals(this.reftree))) {
listener.fatalError("Must specify a reference tree");
return false;
}
final Date startDateOfPopulate;
if (useWorkspace){// _accurevWorkspace != null && _accurevWorkspace.is_useAccurevWorkspace() ) {
AccuRevWorkspaceProcessor acWspace = new AccuRevWorkspaceProcessor(this);
boolean result = acWspace.checkoutWorkspace( this, launcher, listener, server, accurevEnv, jenkinsWorkspace, accurevClientExePath, accurevWorkingSpace, streams, localStream );
if (!result) return result;
startDateOfPopulate = acWspace.get_startDateOfPopulate();
listener.getLogger().println("Calculating latest transaction info for workspace: " + acWspace._accurevWorkspace + ".");
} else if (useReftree) {
AccuRevRefTreeProcessor rTree = new AccuRevRefTreeProcessor(this);
boolean result = rTree.checkoutRefTree( this, launcher, listener, server, accurevEnv, jenkinsWorkspace, accurevClientExePath, accurevWorkingSpace, streams );
if (!result) return result;
startDateOfPopulate = rTree.get_startDateOfPopulate();
} else if ( isUseSnapshot() ) {
final String snapshotName = calculateSnapshotName(build, listener);
listener.getLogger().println("Creating snapshot: " + snapshotName + "...");
build.getEnvironment(listener).put("ACCUREV_SNAPSHOT", snapshotName);
// snapshot command: accurev mksnap -H <server> -s <snapshotName> -b <backing_stream> -t now
final ArgumentListBuilder mksnapcmd = new ArgumentListBuilder();
mksnapcmd.add(accurevClientExePath);
mksnapcmd.add("mksnap");
Command.addServer(mksnapcmd, server);
mksnapcmd.add("-s");
mksnapcmd.add(snapshotName);
mksnapcmd.add("-b");
mksnapcmd.add(localStream);
mksnapcmd.add("-t");
mksnapcmd.add("now");
if (!AccurevLauncher.runCommand("Create snapshot command", launcher, mksnapcmd, null, getOptionalLock(),
accurevEnv, jenkinsWorkspace, listener, logger, true)) {
return false;
}
listener.getLogger().println("Snapshot created successfully.");
PopulateCmd pop = new PopulateCmd();
if ( pop.populate(this, launcher, listener, server, accurevClientExePath, snapshotName, true, "from workspace", accurevWorkingSpace, accurevEnv) ) {
startDateOfPopulate = pop.get_startDateOfPopulate();
} else {
return false;
}
listener.getLogger().println("Calculating latest transaction info for stream: " + localStream + ".");
} else {
/*Change the background color of the stream to white as default, this background color can be optionally changed by the users to green/red upon build success/failure
*using post build action plugins.
*/
{
//For AccuRev 6.0.x versions
SetProperty.setproperty(this, accurevWorkingSpace, listener, accurevClientExePath, launcher, accurevEnv, server, localStream, "#FFFFFF", "style");
//For AccuRev 6.1.x onwards
SetProperty.setproperty(this, accurevWorkingSpace, listener, accurevClientExePath, launcher, accurevEnv, server, localStream, "#FFFFFF", "streamStyle");
}
PopulateCmd pop = new PopulateCmd();
if ( pop.populate(this, launcher, listener, server, accurevClientExePath, localStream, true, "from jenkins workspace", accurevWorkingSpace, accurevEnv) ) {
startDateOfPopulate = pop.get_startDateOfPopulate();
} else {
return false;
}
listener.getLogger().println("Calculating latest transaction info for stream: " + localStream + ".");
}
try {
if (useWorkspace) {
localStream = this.workspace;
}
AccurevTransaction latestTransaction = History.getLatestTransaction(this,
server, accurevEnv, accurevWorkingSpace, listener, accurevClientExePath, launcher, localStream, null);
if (latestTransaction == null) {
throw new NullPointerException("The 'hist' command did not return a transaction. Does this stream have any history yet?");
}
String latestTransactionID = latestTransaction.getId();
String latestTransactionDate = ACCUREV_DATETIME_FORMATTER.format(latestTransaction.getDate());
latestTransactionDate = latestTransactionDate == null ? "1970/01/01 00:00:00" : latestTransactionDate;
listener.getLogger().println("Latest Transaction ID: " + latestTransactionID);
listener.getLogger().println("Latest transaction Date: " + latestTransactionDate);
{
environment.put("ACCUREV_LATEST_TRANSACTION_ID", latestTransactionID);
environment.put("ACCUREV_LATEST_TRANSACTION_DATE", latestTransactionDate);
build.addAction(new AccuRevHiddenParametersAction(environment));
}
} catch (Exception e) {