Skip to content

Commit

Permalink
restapi: use gerrit server prefix
Browse files Browse the repository at this point in the history
when gerrit has a prefix, such as https://server/gerrit the current
implementation is failing as it truncates the RestAPI path.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
  • Loading branch information
alonbl authored and lucamilanesio committed Oct 25, 2018
1 parent ac4b1b2 commit fc0bc91
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private JsonElement gerritApiPut(
throws URISyntaxException, RestApiException {
echo("PUT Gerrit Review %s to %s%s", jsonPayload, uri, path);
GerritAuthData.Basic authData =
new GerritAuthData.Basic(uri.setRawPath("/").toString(), username, password);
new GerritAuthData.Basic(uri.toString(), username, password);
GerritRestApi gerritApi =
new GerritRestApiFactory()
.create(authData, SSLNoVerifyCertificateManagerClientBuilderExtension.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private JsonElement gerritApiPost(
throws URISyntaxException, RestApiException {
echo("Posting Gerrit Review %s to %s%s", jsonPayload, uri, path);
GerritAuthData.Basic authData =
new GerritAuthData.Basic(uri.setRawPath("/").toString(), username, password);
new GerritAuthData.Basic(uri.toString(), username, password);
GerritRestApi gerritApi =
new GerritRestApiFactory()
.create(authData, SSLNoVerifyCertificateManagerClientBuilderExtension.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Gerrit implements Serializable {
script.scm.getRepositories().each {
String name = it.getName()
if (it.getName() == rname) {
gerritApiPost(it.getURIs()[0], path, script.USERNAME, script.PASSWORD, jsonPayload)
gerritApiPost(new GerritURI(it.getURIs()[0]).getApiURL(), path, script.USERNAME, script.PASSWORD, jsonPayload)
}
}
}
Expand All @@ -79,7 +79,7 @@ class Gerrit implements Serializable {

private def gerritApiPost(URIish uri, String path, String username, String password, String jsonPayload) {
script.echo "Posting Gerrit Review ${jsonPayload} to ${uri}/${path}"
GerritAuthData.Basic authData = new GerritAuthData.Basic(uri.setRawPath("/").toString(), script.USERNAME, script.PASSWORD);
GerritAuthData.Basic authData = new GerritAuthData.Basic(uri.toString(), script.USERNAME, script.PASSWORD);
GerritRestApi gerritApi = new GerritRestApiFactory().create(authData, SSLNoVerifyCertificateManagerClientBuilderExtension.INSTANCE)
def result = gerritApi.restClient().postRequest(path, jsonPayload)
script.echo "Result: ${result}"
Expand Down

0 comments on commit fc0bc91

Please sign in to comment.