Skip to content
Permalink
Browse files
[FIXED JENKINS-25346] - Addresses the workspace issue where files cop…
…ied back to master are not in correct path.
  • Loading branch information
svvivek committed Feb 23, 2015
1 parent 8edc401 commit 6482c22c3a313c0ba8c83c553b1711a3d40c081e
Showing with 14 additions and 4 deletions.
  1. +14 −4 src/main/java/com/michelin/cio/hudson/plugins/copytoslave/CopyToSlaveUtils.java
@@ -28,6 +28,8 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleProject;
import hudson.model.TopLevelItem;
import jenkins.model.Jenkins;
import java.io.File;
import java.io.PrintStream;
import java.util.logging.Level;
@@ -39,10 +41,10 @@
public class CopyToSlaveUtils {

public static FilePath getProjectWorkspaceOnMaster(AbstractBuild build, PrintStream logger) {
return getProjectWorkspaceOnMaster(build.getProject(), logger);
return getProjectWorkspaceOnMaster(build, build.getProject(), logger);
}

public static FilePath getProjectWorkspaceOnMaster(AbstractProject project, PrintStream logger) {
public static FilePath getProjectWorkspaceOnMaster(AbstractBuild build, AbstractProject project, PrintStream logger) {
FilePath projectWorkspaceOnMaster;

// free-style projects
@@ -54,11 +56,19 @@ public static FilePath getProjectWorkspaceOnMaster(AbstractProject project, Prin
projectWorkspaceOnMaster = new FilePath(new File(freeStyleProject.getCustomWorkspace()));
}
else {
projectWorkspaceOnMaster = new FilePath(new File(freeStyleProject.getRootDir(), "workspace"));
projectWorkspaceOnMaster = Jenkins.getInstance().getWorkspaceFor(freeStyleProject);
}
}
else {
projectWorkspaceOnMaster = new FilePath(new File(project.getRootDir(), "workspace"));
String pathOnMaster = Jenkins.getInstance().getWorkspaceFor((TopLevelItem)project.getRootProject()).getRemote();
String parts[] = build.getWorkspace().getRemote().
split("workspace" + File.separator + project.getRootProject().getName());
if (parts.length > 1) {
// This happens for the non free style projects (like multi configuration projects, etc)
// So we'll just add the extra part of the path to the workspace
pathOnMaster += parts[1];
}
projectWorkspaceOnMaster = new FilePath(new File(pathOnMaster));
}

try {

0 comments on commit 6482c22

Please sign in to comment.