Skip to content

Commit

Permalink
Merge pull request #39 from voxtok/fix-repo-forall-and-repo-manifest
Browse files Browse the repository at this point in the history
Fix some repo commands
  • Loading branch information
rsandell authored Nov 29, 2016
2 parents a610ba8 + 55a7e73 commit f8ba11f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/hudson/plugins/repo/RepoScm.java
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ public PollingResult compareRemoteRevisionWith(
}

final RevisionState currentState = new RevisionState(
getStaticManifest(launcher, repoDir, listener.getLogger()),
getManifestRevision(launcher, repoDir, listener.getLogger()),
getStaticManifest(launcher, repoDir, listener.getLogger(), env),
getManifestRevision(launcher, repoDir, listener.getLogger(), env),
expandedManifestBranch, listener.getLogger());

final Change change;
Expand Down Expand Up @@ -699,9 +699,9 @@ public void checkout(
throw new IOException("Could not checkout");
}
final String manifest =
getStaticManifest(launcher, repoDir, listener.getLogger());
getStaticManifest(launcher, repoDir, listener.getLogger(), env);
final String manifestRevision =
getManifestRevision(launcher, repoDir, listener.getLogger());
getManifestRevision(launcher, repoDir, listener.getLogger(), env);
final String expandedBranch = env.expand(manifestBranch);
final RevisionState currentState =
new RevisionState(manifest, manifestRevision, expandedBranch,
Expand Down Expand Up @@ -736,7 +736,7 @@ private int doSync(final Launcher launcher, final FilePath workspace,
commands.add("-c");
commands.add("git reset --hard");
int syncCode = launcher.launch().stdout(logger)
.stderr(logger).pwd(workspace).cmds(commands).join();
.stderr(logger).pwd(workspace).cmds(commands).envs(env).join();

if (syncCode != 0) {
debug.log(Level.WARNING, "Failed to reset first.");
Expand Down Expand Up @@ -847,7 +847,8 @@ private boolean checkoutCode(final Launcher launcher,
}

private String getStaticManifest(final Launcher launcher,
final FilePath workspace, final OutputStream logger)
final FilePath workspace, final OutputStream logger,
final EnvVars env)
throws IOException, InterruptedException {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final List<String> commands = new ArrayList<String>(6);
Expand All @@ -858,14 +859,15 @@ private String getStaticManifest(final Launcher launcher,
commands.add("-r");
// TODO: should we pay attention to the output from this?
launcher.launch().stderr(logger).stdout(output).pwd(workspace)
.cmds(commands).join();
.cmds(commands).envs(env).join();
final String manifestText = output.toString();
debug.log(Level.FINEST, manifestText);
return manifestText;
}

private String getManifestRevision(final Launcher launcher,
final FilePath workspace, final OutputStream logger)
final FilePath workspace, final OutputStream logger,
final EnvVars env)
throws IOException, InterruptedException {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final List<String> commands = new ArrayList<String>(6);
Expand All @@ -874,7 +876,7 @@ private String getManifestRevision(final Launcher launcher,
commands.add("HEAD");
launcher.launch().stderr(logger).stdout(output).pwd(
new FilePath(workspace, ".repo/manifests"))
.cmds(commands).join();
.cmds(commands).envs(env).join();
final String manifestText = output.toString().trim();
debug.log(Level.FINEST, manifestText);
return manifestText;
Expand Down

0 comments on commit f8ba11f

Please sign in to comment.