Skip to content

Commit

Permalink
Preserve environment variables
Browse files Browse the repository at this point in the history
In particular, this is useful with the SSH agent plugin
  • Loading branch information
scottanderson committed Oct 27, 2014
1 parent 7489080 commit 12d723a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/hudson/plugins/repo/RepoScm.java
Expand Up @@ -416,7 +416,7 @@ public boolean checkout(
}

private int doSync(final Launcher launcher, final FilePath workspace,
final OutputStream logger)
final OutputStream logger, final EnvVars env)
throws IOException, InterruptedException {
final List<String> commands = new ArrayList<String>(4);
debug.log(Level.FINE, "Syncing out code in: " + workspace.getName());
Expand Down Expand Up @@ -451,7 +451,7 @@ private int doSync(final Launcher launcher, final FilePath workspace,
}
int returnCode =
launcher.launch().stdout(logger).pwd(workspace)
.cmds(commands).join();
.cmds(commands).envs(env).join();
return returnCode;
}

Expand Down Expand Up @@ -495,7 +495,7 @@ private boolean checkoutCode(final Launcher launcher,
}
int returnCode =
launcher.launch().stdout(logger).pwd(workspace)
.cmds(commands).join();
.cmds(commands).envs(env).join();
if (returnCode != 0) {
return false;
}
Expand All @@ -513,7 +513,7 @@ private boolean checkoutCode(final Launcher launcher,
}
}

returnCode = doSync(launcher, workspace, logger);
returnCode = doSync(launcher, workspace, logger, env);
if (returnCode != 0) {
debug.log(Level.WARNING, "Sync failed. Resetting repository");
commands.clear();
Expand All @@ -522,8 +522,8 @@ private boolean checkoutCode(final Launcher launcher,
commands.add("-c");
commands.add("git reset --hard");
launcher.launch().stdout(logger).pwd(workspace).cmds(commands)
.join();
returnCode = doSync(launcher, workspace, logger);
.envs(env).join();
returnCode = doSync(launcher, workspace, logger, env);
if (returnCode != 0) {
return false;
}
Expand Down

2 comments on commit 12d723a

@scottanderson
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abhinavkorpal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still same issue i am facing from been long time.

Please sign in to comment.