Skip to content

Commit

Permalink
Fixed JENKINS-25445
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen committed Nov 5, 2014
1 parent dc06e49 commit 2dea6cb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Expand Up @@ -53,7 +53,7 @@ public void integrate(AbstractBuild<?,?> build, Launcher launcher, BuildListener
boolean found = false;

try {
client = Git.with(listener, build.getEnvironment(listener)).in(build.getWorkspace()).getClient();
client = Git.with(listener, build.getEnvironment(listener)).in(gitbridge.resolveWorkspace(build, listener)).getClient();

logger.fine("Finding remote branches");
for(Branch b : client.getRemoteBranches()) {
Expand Down
Expand Up @@ -9,6 +9,7 @@
import hudson.model.AbstractBuild;
import hudson.plugins.git.Branch;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.extensions.impl.RelativeTargetDirectory;
import hudson.plugins.git.util.BuildData;
import hudson.scm.SCM;
import hudson.util.ArgumentListBuilder;
Expand Down Expand Up @@ -94,7 +95,7 @@ private ProcStarter buildCommand(AbstractBuild<?, ?> build, Launcher launcher, T
b.add(gitExe);
b.add(cmds);
logger.exiting("GitBridge", "buildCommand");// Generated code DONT TOUCH! Bookmark: b2de8fe32eb583d6dac86f020b66bfa4
return launcher.launch().cmds(b).pwd(build.getWorkspace());
return launcher.launch().pwd(resolveWorkspace(build, listener)).cmds(b);
}

/**
Expand Down Expand Up @@ -274,15 +275,26 @@ private String removeOrigin(String branchName) {
return s;
}


public FilePath resolveWorkspace(AbstractBuild<?,?> build, TaskListener listener) throws InterruptedException, IOException {
FilePath ws = build.getWorkspace();
GitSCM scm = findScm(build);
RelativeTargetDirectory rtd = scm.getExtensions().get(RelativeTargetDirectory.class);


if(rtd != null) {
ws = rtd.getWorkingDirectory(scm, build.getProject(), ws, build.getEnvironment(listener), listener);
}

return ws;
}

@Override
protected Commit<?> determineIntegrationHead(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) {
logger.entering("GitBridge", "determineIntegrationHead", new Object[] { build, listener, launcher });// Generated code DONT TOUCH! Bookmark: 9151bd5b4bfbdc724c67fa8d42a44f57
Commit<?> commit = null;
try {
logger.fine(String.format("About to determine integration head for build, for branch %s", getBranch() ) );
GitClient client = Git.with(listener, build.getEnvironment(listener)).in(build.getWorkspace()).getClient();
GitClient client = Git.with(listener, build.getEnvironment(listener)).in(resolveWorkspace(build, listener)).getClient();
for(Branch b : client.getBranches()) {
if(b.getName().contains(getBranch())) {
logger.fine("Found integration head commit sha: "+b.getSHA1String());
Expand Down
Expand Up @@ -57,7 +57,7 @@ public void integrate(AbstractBuild<?,?> build, Launcher launcher, BuildListener
listener.getLogger().println( String.format( "Preparing to merge changes in commit %s to integration branch %s(%s)", gitDataBranch.getSHA1String(), bridge.getBranch(), integrationSHA) );
boolean found = false;
try {
client = Git.with(listener, build.getEnvironment(listener)).in(build.getWorkspace()).getClient();
client = Git.with(listener, build.getEnvironment(listener)).in(gitbridge.resolveWorkspace(build, listener)).getClient();

logger.fine("Finding remote branches");
for(Branch b : client.getRemoteBranches()) {
Expand Down
Expand Up @@ -10,6 +10,7 @@
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.impl.CleanCheckout;
import hudson.plugins.git.extensions.impl.PruneStaleBranch;
import hudson.plugins.git.extensions.impl.RelativeTargetDirectory;
import hudson.slaves.DumbSlave;
import hudson.triggers.SCMTrigger;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -226,6 +227,7 @@ private FreeStyleProject configurePretestedIntegrationPlugin(boolean runOnSlave)
List<GitSCMExtension> gitSCMExtensions = new ArrayList<GitSCMExtension>();
gitSCMExtensions.add(new PruneStaleBranch());
gitSCMExtensions.add(new CleanCheckout());
gitSCMExtensions.add(new RelativeTargetDirectory("rel-folder"));

GitSCM gitSCM = new GitSCM(repoList,
Collections.singletonList(new BranchSpec("origin/ready/**")),
Expand Down

0 comments on commit 2dea6cb

Please sign in to comment.