Skip to content

Commit fc0bc91

Browse files
alonbllucamilanesio
authored andcommitted
restapi: use gerrit server prefix
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 <[email protected]>
1 parent ac4b1b2 commit fc0bc91

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/main/java/jenkins/plugins/gerrit/workflow/GerritCommentStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private JsonElement gerritApiPut(
132132
throws URISyntaxException, RestApiException {
133133
echo("PUT Gerrit Review %s to %s%s", jsonPayload, uri, path);
134134
GerritAuthData.Basic authData =
135-
new GerritAuthData.Basic(uri.setRawPath("/").toString(), username, password);
135+
new GerritAuthData.Basic(uri.toString(), username, password);
136136
GerritRestApi gerritApi =
137137
new GerritRestApiFactory()
138138
.create(authData, SSLNoVerifyCertificateManagerClientBuilderExtension.INSTANCE);

src/main/java/jenkins/plugins/gerrit/workflow/GerritReviewStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private JsonElement gerritApiPost(
129129
throws URISyntaxException, RestApiException {
130130
echo("Posting Gerrit Review %s to %s%s", jsonPayload, uri, path);
131131
GerritAuthData.Basic authData =
132-
new GerritAuthData.Basic(uri.setRawPath("/").toString(), username, password);
132+
new GerritAuthData.Basic(uri.toString(), username, password);
133133
GerritRestApi gerritApi =
134134
new GerritRestApiFactory()
135135
.create(authData, SSLNoVerifyCertificateManagerClientBuilderExtension.INSTANCE);

src/main/resources/jenkins/plugins/gerrit/workflow/Gerrit.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Gerrit implements Serializable {
6767
script.scm.getRepositories().each {
6868
String name = it.getName()
6969
if (it.getName() == rname) {
70-
gerritApiPost(it.getURIs()[0], path, script.USERNAME, script.PASSWORD, jsonPayload)
70+
gerritApiPost(new GerritURI(it.getURIs()[0]).getApiURL(), path, script.USERNAME, script.PASSWORD, jsonPayload)
7171
}
7272
}
7373
}
@@ -79,7 +79,7 @@ class Gerrit implements Serializable {
7979

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

0 commit comments

Comments
 (0)