-
Notifications
You must be signed in to change notification settings - Fork 360
[JENKINS-75083] Build statuses do not appear in list of pull requests in Bitbucket Server #954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-75083] Build statuses do not appear in list of pull requests in Bitbucket Server #954
Conversation
dbf4b14
to
26c904d
Compare
@nfalco79, does this need an issue in Jira? |
The user interface of Bitbucket Server also supports these in build statuses:
|
ad6e5d5
to
de40f20
Compare
Could be better to keep track of undocumented behaviour |
This comment was marked as outdated.
This comment was marked as outdated.
I know but this is a SCM plugin I did not want add dependency to the junt test (or competitor) just to provide something supported only by the server instance (for which I do not have long plan). When I added the refname attribute I had in mind a possible extension point (limited to extra fields only) to be implemented in other Bitbucket plugins. |
I first tried installing the HPI built from this PR, but got an error
Not sure whether that is by design or whether I did something wrong with Maven. I then rebased onto 933.1.0, got commit dbf3823, built HPI from that, and installed. The result seems to be working in a pull request from the same repository, and in a pull request from a fork; I did not test a pull request to a fork. This version incorrectly shows 933.1.0 as its version number though; I should have rebased onto 737df70 instead. It'll probably take a few days before I continue this. |
Is this related to JENKINS-74970 ? |
Not really. JENKINS-74970 is specific to pull requests from a fork, and the fix would be in error handling and logging. The issue that this PR fixes is with all pull requests, whether from the same repository or from a fork. |
It's because in master there is a bug fix that requires a release of the git-plugin (some people are waiting for it). |
de40f20
to
50464ae
Compare
Filed JENKINS-75082 to request posting test results to Bitbucket Server. |
Filed JENKINS-75083 for the problem that this PR is intended to fix. |
I intend to test some more with other PR build strategies before I mark this ready to review. |
50464ae
to
c8c38ab
Compare
I rebased this PR onto |
Manually tested scenarios with commit c8c38ab and Bitbucket Server.
|
What does this mean ? What about Data Center users ? |
I express my concern about spend double effort to support datacenter instance when there is already other plugin developed and mantained by atlassian itself. So this year I would discuss with other plugin developers about this situation and decide what do. |
The question would be, why the atlassian-bitbucket-server-integration was developed years (arround 2019) way after the bitbucket-branch-source-plugin I tested several times since it's inception the atlassian-bitbucket-server-integration and never my needs (for example poor JobDSL integration, missing traits, not possible to override the remote name JENKINS-67890, many dependencies instead of API plugin (https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin/blob/master/pom.xml#L54-L79) etc... And some other issues that I don't remember now |
I would like to keep this plugin compatible with on-premises Bitbucket for now, but I am not very experienced with Java and cannot make large changes quickly. @nfalco79, are you planning some changes to this plugin that would be easier if compatibility with Bitbucket Data Center and Server were removed? |
If you are planning large changes to this plugin and don't want to spend time adapting the Bitbucket Server client to them, then I would like to know in advance so that I can try to get time for that. If Bitbucket Server support is removed from this plugin, I think I'll try to maintain it in a private fork and port security fixes to that, while investigating whether it is feasible to port pipelines to the Bitbucket Server Integration plugin. But I don't entirely trust Atlassian's intentions with that plugin because of their stated goal to move customers to cloud services. So there's a risk that they'd make some intolerable change to it or shut it down. |
I think Bitbucket DataCenter support is crucial for this plugin and it's 70'000 installation. I doubt there is only Cloud user using it While I highly appreciate many bugs and feature were resolved recently, I think due to this plugin adoption DataCenter support cannot be removed (As a reminder https://www.jenkins.io/project/governance/#compatibility-matters) I also volunteer also to give help for this plugin |
Ok this is sad to hear, this means I have to support both scenarios for years until the support has been improved by atlassian team. |
I don't plan to remove any current features, but I won't implement any new features specific to the datacenter (as was done for the mirror feature), relying only on the documentation without even the possibility to test it myself. This means that the development of new features will be fast for the cloud version while it may not work properly, or at all, in the datacenter version. What I can say is that since I will be replacing the deprecated Bitbucket server APIs with the new ones, this plugin will no longer support the server version declared in EOL. I mean... server version older than 7.x will no longer work. I don't want to complicate the logic of this plugin that not even Atlassian wants to provide support for. Any help from datecenter users in bugfix (like this) and test like this feature is/will be welcome. |
I agreed for the EOL. I doesn't make sense to support a datacenter (or server) version that is end of life. If for some reason users cannot upgrade, they can still stay on an older version of the plugin |
OffTopic I have a flexible plan, but what I would do in the next months is (the order does not mean priority):
|
@nfalco79 do you have experience on Apache http vs. okhttp vs. java.net.http? I recently ported some code from okhttp to java.net.http (to minimise dependencies) and the API was pretty similar; but java.net.http apparently supports HTTP Basic authentication only and it is not possible to provide an authenticator object that would handle other authentication schemes. Although this can be worked around by making another HttpRequest. |
I want migrate to http 5.x because of this Line 43 in dcd189d
Apache client has too many feature that jdk does not support and I have write from scratch by myself. |
Perhaps a telemetry experiment could be done. The payload would be based on the "Bitbucket Endpoints" list in the "System" configuration:
If the plugin was installed only to satisfy dependencies, then both would be "no". However, the results of this telemetry could be misleading if the company has migrated all projects out of Bitbucket Server but has not unregistered the defunct endpoint from Jenkins. |
… in Bitbucket Server (#954) Set "ref" in PR build status for Bitbucket Server
The commit 7ac886d switched to the newer repository commit build status api. This introduced a regression in the case the PR source repository is not the same as the target, for example a person fork. In this case the bitbucket api created from the PR head will point to the fork repo and may result in a 401 error if the credentials don't have the necessary permissions. ``` ERROR: Could not send notifications com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: HTTP/1.1 401 Response: {"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]} ``` This change will force the bitbucket api instance to be the target repo which is the appropriate target for the notification. The old api was commit hash centric, not project centric, so the api client owner/repo didn't matter. This change also reverts changes introduced by jenkinsci#954 to the refName parameter. Since notification is on the targget repo, the head ref branch may not exist on the target and result in no status update. No changes were made to the Bitbucket Cloud code path.
The commit 7ac886d switched to the newer repository commit build status api. This introduced a regression in the case the PR source repository is not the same as the target, for example a person fork. In this case the bitbucket api created from the PR head will point to the fork repo and may result in a 401 error if the credentials don't have the necessary permissions. ``` ERROR: Could not send notifications com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: HTTP/1.1 401 Response: {"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]} ``` This change will force the bitbucket api instance to be the target repo which is the appropriate target for the notification. The old api was commit hash centric, not project centric, so the api client owner/repo didn't matter. This change also reverts some changes introduced by jenkinsci#954 to the refName parameter. While local testing has shown that by changing the bitbucket client to point to the target repo, setting the refName to null works in all cases, this change has been restricted to only cases when the source repo is the same as the target. No changes were made to the Bitbucket Cloud code path.
When posting a build status from a pull-request job to Bitbucket Server or Data Center, set the "ref" property to match the source branch, e.g. "refs/heads/myfeature". This fixes the problem that Bitbucket Server stopped showing build statuses in the list of pull requests when the plugin started using the newer build-status API in #930.
This PR does not change how the plugin posts a build status to Bitbucket Cloud. That case will have
"ref": null
for pull-request jobs, like before.Fix JENKINS-75083.
Your checklist for this pull request
Manually tested with Bitbucket Server; see [JENKINS-75083] Build statuses do not appear in list of pull requests in Bitbucket Server #954 (comment).