简体   繁体   English

如何使用springboot使用bitbucket rest api获取所有存储库?

[英]How can i use the bitbucket rest api to get all the repos using springboot?

How can I use the bitbucket rest API to get all the repos in java? 如何使用bitbucket rest API获取Java中的所有存储库?

How can I do it using spring boot? 如何使用Spring Boot进行操作?

Can anybody provide me with an example of it? 有人可以给我提供一个例子吗?

For fetching repositories list: 对于获取存储库列表:

You can use this endpoint BitBucket Repositories API 您可以使用此终结点BitBucket存储库API

For repository cloning: 对于存储库克隆:

You can use jGit library for this . 您可以为此使用jGit库

All you have to do is setup auth for BitBucket server (Create SSH key and use it with library). 您所要做的就是为BitBucket服务器设置身份验证(创建SSH密钥并将其与库一起使用)。

Or you can directly use commands with Java Process API (java/lang/Process). 或者,您可以直接将命令与Java Process API(java / lang / Process)一起使用。

Runtime.getRuntime().exec("git clone ...your repos...");

You can use UniRest for this. 您可以为此使用UniRest Sample code to get all the repos of a user with name John is like this. 获取名称为John的用户的所有存储库的示例代码是这样的。

HttpResponse<String> response = 
Unirest.get("https://api.bitbucket.org/2.0/repositories/John")
.header("authorization", "Bearer  <token>")
.header("content-type", "application/json")
.header("accept", "application/json")
.asString();

Note : This is for BitBucket cloud. 注意:这适用于BitBucket云。 You can do the same for bitbucket server using the corresponding url. 您可以使用相应的网址对bitbucket服务器执行相同的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM