@Override
public Map<String, String> getAnnotations(Kind kind) {
if (isOnline() && (kind.isController() || kind == Kind.SERVICE)) {
Map<String, String> annotations = new HashMap<>();
MavenProject rootProject = MavenUtil.getRootProject(getProject());
String repoName = rootProject.getArtifactId();
try (Repository repository = GitUtil.getGitRepository(getProject())) {
if (repository != null) {
String gitCommitId = GitUtil.getGitCommitId(repository);
if (gitCommitId != null) {
addGitServiceUrl(annotations, repoName, gitCommitId);
} else {
log.debug("No Git commit id found");
}
} else {
log.debug("No local Git repository found");
}
} catch (IOException | GitAPIException e) {
log.error("Cannot extract Git information for adding to annotations: " + e, e);
}
addJenkinsServiceUrl(annotations, repoName);
return annotations;
}
return null;
}