question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Single file retrieval from PR uses outdated Bitbucket API

See original GitHub issue

Your 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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
xabolcscommented, Nov 4, 2020

@bitwiseman enabling “Call changes API” doesn’t help for my Bitbucket Server 7 endpoint. But manually changing merge to from 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 more merge for newer PRs:

c5fe5646515e58eb67958cbb181ad301649fea97	refs/pull-requests/1422/from
69df8d813c2d96d0adee7103793d9b82951886fd	refs/pull-requests/1422/merge
c5fe5646515e58eb67958cbb181ad301649fea97	refs/pull-requests/1423/from
ad4b79b5f0809a802902df865a46e378fa04f0a4	refs/pull-requests/1423/merge
cf34c974f84a8e82886de42c82be97671e5777a5	refs/pull-requests/1685/from
d8d5f5fed6bf59a6cf406ad07b31fdb187f4b340	refs/pull-requests/2529/from
39613491f3aa82e6b2d15f7e3ffce5d57fc49fb6	refs/pull-requests/2781/from
05d9a108d265886b0737cd5b9815cea43828978f	refs/pull-requests/2802/from
9e70491d7b649c5aedd921b8aecbca50c82872ba	refs/pull-requests/2803/from
f791077eed5b19c03a7567023480467a88f2ec6e	refs/pull-requests/2804/from

Of course, using ChangeRequestCheckoutStrategy.HEAD works around the problem

Screenshot_2020-11-04 Config  Jenkins

1reaction
bitwisemancommented, Nov 24, 2020

@xabolcs We’d welcome a PR that improves matters.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found