Single file retrieval from PR uses outdated Bitbucket API
See original GitHub issueYour checklist for this issue
-
[x ] Jenkins version
-
[ x] Plugin version
-
Bitbucket cloud
-
[ x] Bitbucket server and version
Description
Jenkins version: 2.235.3 Plugin version: 2.9.1 Bitbucket server and version: 7.4.0
When the plugin needs to retrieve a single file from a pull-request in Bitbucket server it uses the at=pull-request reference which doesn’t seem to be supported post Bitbucket 7+.
Example snippet that triggers this behaviour
pipeline {
agent {
kubernetes {
customWorkspace 'myworkspace'
label 'mylabel'
yamlFile 'Jenkinsfile.yml'
defaultContainer 'java'
}
}
stages {
stage("Build") {
steps {
sh "echo 'hello'"
}
}
}
}
(line 7 with yamlFile being the culprit)
Stacktrace:
java.io.FileNotFoundException: URL: /rest/api/1.0/projects/test/repos/my-repro/browse/Jenkinsfile.yml?at=pull-requests%2F14%2Fmerge&start=0&limit=500
at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:854)
at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getFileContent(BitbucketServerAPIClient.java:1149)
at com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile.content(BitbucketSCMFile.java:98)
at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:335)
This is related to issue #294 where a similar issue was fixed, but this feels like a case that was left behind.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Pullrequests - The Bitbucket Cloud REST API
List pull requests ... Returns all pull requests on the specified repository. By default only open pull requests are returned. This can be...
Read more >REST Resources Provided By: Bitbucket Server - REST
/rest/api/1.0/admin/permissions/users?filter. This is a paged API. Retrieve a page of users that have been granted at least one global permission. The ...
Read more >The Bitbucket Cloud REST API - Atlassian Developer
The purpose of this section is to describe how to authenticate when making API calls using the Bitbucket REST API. Oauth 2. Making...
Read more >REST Resources Provided By: Bitbucket Server - REST
This is a paged API. Retrieve a page of users. The authenticated user must have the LICENSED_USER permission to call this resource. request...
Read more >Use Bitbucket REST API version 1 - Atlassian Support
Bitbucket Cloud REST API version 1 was removed from the REST API permanently on 29 April 2019. There is temporary support for limited...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bitwiseman enabling “Call changes API” doesn’t help for my Bitbucket Server 7 endpoint. But manually changing
merge
tofrom
in the URL (/rest/api/1.0/projects/test/repos/my-repro/browse/Jenkinsfile.yml?at=pull-requests%2F14%2Ffrom&start=0&limit=500
) helps.Sure, enabling “Call changes API” helps for other areas in the Jenkins - Bitbucket Server integration, but not for lightweight checkout.
But the problem is the same -
git ls-remote
shows there is no moremerge
for newer PRs:Of course, using
ChangeRequestCheckoutStrategy.HEAD
works around the problem@xabolcs We’d welcome a PR that improves matters.