Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 ea62814
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/hudson/plugins/git/GitSCM.java
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit ea62814

Please sign in to comment.