Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-31004 - Check gerrit-trigger REST API settings before plugin …
…execution
  • Loading branch information
aquarellian committed Oct 19, 2015
1 parent 1487f16 commit 55bd463
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/messages.properties
Expand Up @@ -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.