Skip to content
Permalink
Browse files
[FIXED JENKINS-20427] [FIXED JENKINS-14276] expanded vars in branch s…
…pec for remote polling
  • Loading branch information
ndeloof committed Sep 24, 2014
1 parent fc5c7ec commit ea62814db213b41b0e8fe99dbca6898aa369da97
Showing 1 changed file with 6 additions and 4 deletions.
@@ -462,6 +462,7 @@ public boolean requiresWorkspaceForPolling() {
for (GitSCMExtension ext : getExtensions()) {
if (ext.requiresWorkspaceForPolling()) return true;
}
// TODO would need to use hudson.plugins.git.util.GitUtils.getPollEnvironment
return getSingleBranch(new EnvVars()) == null;
}

@@ -494,16 +495,17 @@ private PollingResult compareRemoteRevisionWithImpl(AbstractProject<?, ?> projec
final String singleBranch = getSingleBranch(lastBuild.getEnvironment(listener));

// fast remote polling needs a single branch and an existing last build
if (!requiresWorkspaceForPolling() && buildData.lastBuild != null && buildData.lastBuild.getMarked() != null) {

// FIXME this should not be a specific case, but have BuildChooser tell us if it can poll without workspace.
if (singleBranch != null // branch spec can be resolved to a single branch
&& buildData.lastBuild != null && buildData.lastBuild.getMarked() != null // we know previous build commit
&& !requiresWorkspaceForPolling() // remote polling hasn't been intentionally disabled
) {

final EnvVars environment = GitUtils.getPollEnvironment(project, workspace, launcher, listener, false);

GitClient git = createClient(listener, environment, project, Jenkins.getInstance(), null);

String gitRepo = getParamExpandedRepos(lastBuild, listener).get(0).getURIs().get(0).toString();
ObjectId head = git.getHeadRev(gitRepo, getBranches().get(0).getName());
ObjectId head = git.getHeadRev(gitRepo, singleBranch);
if (head != null){
listener.getLogger().println("[poll] Latest remote head revision is: " + head.getName());
if (buildData.lastBuild.getMarked().getSha1().equals(head)) {

0 comments on commit ea62814

Please sign in to comment.