Skip to content

Commit 7c76193

Browse files
alexey-pelykhjetersen
authored andcommitted
[JENKINS-56926] Restore support of Jenkinsfile located in subdirectory (#180)
### Your checklist for this pull request - [x] Make sure you are requesting to **pull a topic/feature/bugfix branch** (right side) and not your master branch! - [x] Please describe what you did - [x] Link to relevant GitHub issues or pull requests - [x] Link to relevant [Jenkins JIRA issues](https://issues.jenkins-ci.org) - [x] Did you provide a test-case? That demonstrates feature works or fixes the issue. <!-- Put an `x` into the [ ] to show you have filled the information below Describe your pull request below --> ### Description Addressing regression introduced by brainbeanapps@868676d in version 2.4.3 (https://issues.jenkins-ci.org/browse/JENKINS-56926)
1 parent fd7b95f commit 7c76193

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile;
5555
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
5656
import com.damnhandy.uri.template.UriTemplate;
57+
import com.damnhandy.uri.template.impl.Operator;
5758
import com.fasterxml.jackson.core.type.TypeReference;
5859
import edu.umd.cs.findbugs.annotations.CheckForNull;
5960
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -387,11 +388,11 @@ public void postCommitComment(@NonNull String hash, @NonNull String comment) thr
387388
@Override
388389
public boolean checkPathExists(@NonNull String branchOrHash, @NonNull String path)
389390
throws IOException, InterruptedException {
390-
String url = UriTemplate.fromTemplate(REPO_URL_TEMPLATE + "/src{/branchOrHash,path}")
391+
String url = UriTemplate.fromTemplate(REPO_URL_TEMPLATE + "/src{/branchOrHash,path*}")
391392
.set("owner", owner)
392393
.set("repo", repositoryName)
393394
.set("branchOrHash", branchOrHash)
394-
.set("path", path)
395+
.set("path", path.split(Operator.PATH.getSeparator()))
395396
.expand();
396397
int status = headRequestStatus(url);
397398
if (HttpStatus.SC_OK == status) {

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public BitbucketCommit call() throws Exception {
147147
private static final String API_PULL_REQUESTS_PATH = API_REPOSITORY_PATH + "/pull-requests{?start,limit,at,direction,state}";
148148
private static final String API_PULL_REQUEST_PATH = API_REPOSITORY_PATH + "/pull-requests/{id}";
149149
private static final String API_PULL_REQUEST_MERGE_PATH = API_REPOSITORY_PATH + "/pull-requests/{id}/merge";
150-
static final String API_BROWSE_PATH = API_REPOSITORY_PATH + "/browse/{+path}{?at}";
150+
static final String API_BROWSE_PATH = API_REPOSITORY_PATH + "/browse{/path*}{?at}";
151151
private static final String API_COMMITS_PATH = API_REPOSITORY_PATH + "/commits{/hash}";
152152
private static final String API_PROJECT_PATH = API_BASE_PATH + "/projects/{owner}";
153153
private static final String API_COMMIT_COMMENT_PATH = API_REPOSITORY_PATH + "/commits{/hash}/comments";

src/test/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClientTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cloudbees.jenkins.plugins.bitbucket.server.client;
22

33
import com.damnhandy.uri.template.UriTemplate;
4+
import com.damnhandy.uri.template.impl.Operator;
45
import org.junit.Assert;
56
import org.junit.Test;
67

@@ -14,7 +15,7 @@ public void repoBrowsePathFolder() {
1415
.fromTemplate(API_BROWSE_PATH)
1516
.set("owner", "test")
1617
.set("repo", "test")
17-
.set("path", "folder/Jenkinsfile")
18+
.set("path", "folder/Jenkinsfile".split(Operator.PATH.getSeparator()))
1819
.set("at", "fix/test")
1920
.expand();
2021
Assert.assertEquals("/rest/api/1.0/projects/test/repos/test/browse/folder/Jenkinsfile?at=fix%2Ftest", expand);
@@ -26,7 +27,7 @@ public void repoBrowsePathFile() {
2627
.fromTemplate(API_BROWSE_PATH)
2728
.set("owner", "test")
2829
.set("repo", "test")
29-
.set("path", "Jenkinsfile")
30+
.set("path", "Jenkinsfile".split(Operator.PATH.getSeparator()))
3031
.expand();
3132
Assert.assertEquals("/rest/api/1.0/projects/test/repos/test/browse/Jenkinsfile", expand);
3233
}

0 commit comments

Comments
 (0)