Skip to content
Permalink
Browse files
JENKINS-31004 - Check gerrit-trigger REST API settings before plugin …
…execution
  • Loading branch information
aquarellian committed Oct 19, 2015
1 parent 1487f16 commit 55bd4639b5c9255e4fe3e008347f0e74d8ac4c7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
@@ -196,11 +196,16 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
logError(listener, "jenkins.plugin.error.gerrit.config.empty", Level.SEVERE);
return false;
}
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();

if (!gerritConfig.isUseRestApi()){
logError(listener, "jenkins.plugin.error.gerrit.restapi.off", Level.SEVERE);
return false;
}
if (gerritConfig.getGerritHttpUserName() == null) {
logError(listener, "jenkins.plugin.error.gerrit.user.empty", Level.SEVERE);
return false;
}
GerritRestApiFactory gerritRestApiFactory = new GerritRestApiFactory();
GerritAuthData.Basic authData = new GerritAuthData.Basic(gerritConfig.getGerritFrontEndUrl(),
gerritConfig.getGerritHttpUserName(), gerritConfig.getGerritHttpPassword());
GerritApi gerritApi = gerritRestApiFactory.create(authData);
@@ -236,7 +241,7 @@ public boolean apply(@Nullable String input) {
LOGGER.log(Level.INFO, "Review has been sent");
} catch (RestApiException e) {
LOGGER.severe(e.getMessage());
return true;
return false;
}

return true;
@@ -17,4 +17,5 @@ jenkins.plugin.error.gerrit.user.empty=Gerrit authentication is not configured.
jenkins.plugin.error.sonar.report.not.exists=Sonar report '%s' does not exist. Please check plugin settings
jenkins.plugin.validation.review.severity.unknown=Unknown severity
jenkins.plugin.validation.review.category.unknown=Unknown category
jenkins.plugin.validation.review.score.not.numeric=Score should be numeric
jenkins.plugin.validation.review.score.not.numeric=Score should be numeric
jenkins.plugin.error.gerrit.restapi.off=RestAPI in Gerrit-Trigger settings must be enabled

0 comments on commit 55bd463

Please sign in to comment.