lvermeulen / bitbucket.net Goto Github PK
View Code? Open in Web Editor NEWC# client for Atlassian Bitbucket Server
License: MIT License
C# client for Atlassian Bitbucket Server
License: MIT License
As it uses Flurl the authentication is actually cached per host for at least the first request. What this means is that if I use one bitbucket client and then create a second one with other credentials it would actually use the credentials from the first one.
To be resolved I think that instead of invoking requests directly agains the string using the flurl extensions a flurl client should be used and the bitbucket client should implement IDisposable.
Loving this library, made integrating into our bit bucket server much easier. Better than Atlassian Stash.
Would like to suggest having the ability to Authenticate with Bearer tokens though.
This seems more secure than authenticating with username and password. And does not seem hard to implement.
Using WithOAuthBearerToken instead of WithBasicAuth in GetBaseUrl.
Thanks!
While using DeclinePullrequest Method,it is failing with status code 405.
FlurlHttpException: DELETE http://bitbucket.org/rest/api/1.0/projects/{projectkey}/repos/{slug}/pull-requests/1898/decline?version=2 failed with status code 405 ().
This is the method I have defined using the bitbucket package
`public bool DeclineUnapprovedBuildMasterPullRequests()
{
var openBuildMasterUnapprovedPullRequests = GetOpenBuildMasterPullRequests().Where(pr=> pr.Reviewers.Count(rev => rev.Approved) <PULL_APPROVAL_THRESHOLD).ToList();
if (openBuildMasterUnapprovedPullRequests.Count > 0)
{
foreach (var pullRequest in openBuildMasterUnapprovedPullRequests)
{
var declinePullRequest = bitbucketClient.DeclinePullRequestAsync(settings.ProjectKey, settings.RepositorySlug, pullRequest.Id, pullRequest.Version).Result;
if (!declinePullRequest)
return false;
}
}
return true;
}
`
Bitbucket introduced an API for Reports and Annotations.
It might be a good idea to provide classes and methods in library.
Links:
https://confluence.atlassian.com/bitbucketserver/code-insights-966660485.html
https://docs.atlassian.com/bitbucket-server/rest/7.8.1/bitbucket-code-insights-rest.html
@lvermeulen, at the company I work for we use this library in one of our internal repos. There are some things that we would like to fix on this library. However, it doesn't appear that you spend much time actively maintaining this repo. So, could you add me as one of the maintainers of this repository please? Then I can help you maintain this library.
I'm not sure which API version introduced the change, but tasks on pull requests are now called "blocker-comments". Would it be possible to add support for those?
Per the docs here: https://docs.atlassian.com/bitbucket-server/rest/7.4.0/bitbucket-rest.html
seems to mirror
fairly closely.
Hi, thanks for the great library!
According to https://community.atlassian.com/t5/Bitbucket-questions/REST-API-how-to-check-if-a-PR-has-conflict-s/qaq-p/716529
there is a really helpful api endpoint to determine the mergeability of a pull request:
https://bitbucket.org/api/1.0/repositories/<org_or_profile>/<repo_name>/pullrequests/<pull_request_id>/conflict-status
Do you have any plans on integrating that?
Thanks in advance!
I have a console app using this library. Querying the list of repositories for one server takes 90 seconds. I can't cancel the command because I can't pass the CancellationToken through the methods. I looked at forking this but there were too many methods for me to update. I ended up with the following workaround. It works but took my a while to determine how to do. Maybe it would even be helpful just to link to an example like this until such time CancellationToken is supported?
MyHttpClientHandler.CancellationToken = context.CancellationToken;
FlurlHttp.GlobalSettings.HttpClientFactory = new MyDefaultHttpClientFactory();
public class MyDefaultHttpClientFactory : DefaultHttpClientFactory
{
public override HttpMessageHandler CreateMessageHandler() => (HttpMessageHandler)new MyHttpClientHandler()
{
AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate)
};
}
public class MyHttpClientHandler : HttpClientHandler
{
internal static CancellationToken CancellationToken;
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// ignore the default token
return base.SendAsync(request, CancellationToken);
}
protected override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken)
{
// ignore the default token
return base.Send(request, CancellationToken);
}
}
BrowseProjectRepositoryPath returns file content as an array of text lines.
If the text line size is more than a constant (~5000 chars), the returned text is truncated, and the "Truncated" property value is true on the model.
public class Line
{
public string Text { get; set; }
public bool? Truncated { get; set; }
}
Great work!
Have you thought about introducing interfaces to allow for mocking in tests? Really the only thing holding me back from using this library.
hi,
would be great if https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests would be included in this library
thanks
Hi,
This project needs some documentation. It's not clear how to use the API.
It's also not clear if this works with Bitbucket cloud.
hi
in our context we need a signed dll, could you provide one?
thanks
When adding comments to a PR, this API call expects an achor
key. This allows the comment to be applied to a line of a file in a diff.
As far as I can tell, CreatePullRequestCommentAsync
doesn't format the JSON data with the anchor
key, meaning that comments only get applied at the overview level.
Hi,
since the last release I get an 415 return code when I try to execute a merge:
POST https://bitbucket.*****.com/rest/api/1.0/projects/TM/repos/tm5/pull-requests/486/merge?version=11 failed with status code 415
Any idea what the reason might be? The previous release worked fine for me.
There is a use case when an application may get/modify a file content without the ability to save a file on a hard drive.
BrowseProjectRepositoryPathAsync allows us to read file content as a string, but UpdateProjectRepositoryPathAsync doesn't allow us to push it without creating a physical file.
this static ctor changes the default JSON serialization settings in the application.
I think this is a problem, since other code may rely on the "default" set of defaults.
I don't expect a library to change the global settings in my application..
For example, in the application I'm working on now, we have many integrations with many 3rd party APIs.
I spent more time than I would've liked trying to figure out why an integration with service X was working as expected normally, but not working only on certain servers / certain customers.
turns out that, as long as the bitbucket integration wasn't turned on, everything was great. but once we turned on integration for bitbucket AND service X, service X stopped working as expected.
that's because Bitbucket.NET
changed how the requests to service X were serialized!
I'd like to not have to use my bitbucket username and password for an automated script to run.
Example code:
var _client = new BitbucketClient("https://myprivatebitbucketrepo.example.com", () =>
@"
-----BEGIN OPENSSH PRIVATE KEY-----
insert your private key here
-----END OPENSSH PRIVATE KEY-----
"
);
Hi,
I stumbled upon a problem when deleting branches using DeleteRepoBranchAsync:
Unhandled Exception: System.AggregateException: One or more errors occurred. (DELETE https://bitbucketserver/rest/branch-utils/1.0/projects/proj/repos/repo/branches failed with status code 415 ().) ---> Flurl.Http.FlurlHttpException: DELETE https://bitbucketserver/rest/branch-utils/1.0/projects/proj/repos/repo/branches failed with status code
415 ().
Any idea why this blows up? I've got no fancy characters in the branch name and according to https://docs.atlassian.com/bitbucket-server/rest/5.9.0/bitbucket-rest.html
everything should be fine :(
Thx in advance!
I get a 404 when trying to add a pull request comment that is not linked to a specific line of code. This despite being able to do so if I POST to the same URI, with a body of just { text = "comment" }. I imagine it is because the rest of the JSON body is actually being populated with data that does not apply in a global PR comment.
hi,
would be great if the endpoint could already provide properties, we have this rest answer:
"properties": {
"jira-key": [
"ticket"
]
}
But the properties are missing from the Commit.
I can get the data from the comment, but then i need to run some regx to get the tickets. Would be nice to get directly the data from the endpoint.
thanks
I love this library, and am trying to understand if I am just misunderstanding how it works, or if I have a feature request ;)
when I look at the json data for a pull request, there is a comments and tasks parameter array. However this library doesn't have a comments nor tasks array inside of Comment. I can't figure out how to recursively dig into the tree of comments.
Thank You, Josh
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.