Skip to content

Commit

Permalink
[FIXED JENKINS-27383] Don't attempt to fetch tag message when no tag …
Browse files Browse the repository at this point in the history
…was found.
  • Loading branch information
Christopher Orr committed Mar 12, 2015
1 parent dbe1928 commit 1fb0506
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -16,6 +16,7 @@
import java.util.logging.Logger;

import static hudson.Util.fixEmpty;
import static hudson.Util.fixEmptyAndTrim;

public class GitTagMessageExtension extends GitSCMExtension {

Expand Down Expand Up @@ -49,6 +50,9 @@ public void onCheckoutCompleted(GitSCM scm, AbstractBuild<?, ?> build, GitClient
} else {
// This build was triggered for a named branch, or for a particular commit hash
tagName = getTagName(git, commit);
if (tagName == null) {
return;
}
}

// Retrieve the tag message for the given tag name, then store it
Expand All @@ -70,6 +74,7 @@ private static String getTagName(GitClient git, String commit) throws Interrupte
// This should return a tag name (e.g. "beta42") or the nearest tag name and an offset ("beta42-5-g123abcd")
tagDescription = fixEmpty(git.describe(commit)); // "git describe --tags <commit>"
} catch (GitException e) {
// If there are no tags nearby, git returns a non-zero exit code, which throws this exception
LOGGER.warning(String.format("Fetching tag info for '%s' threw exception: %s", commit, e.getMessage()));
}
if (tagDescription == null) {
Expand All @@ -83,7 +88,7 @@ private static String getTagName(GitClient git, String commit) throws Interrupte
return null;
}

return tagDescription;
return fixEmptyAndTrim(tagDescription);
}

@Extension
Expand Down

0 comments on commit 1fb0506

Please sign in to comment.