java - 如何使用 bitbucket api v2.0 在 gradle 中添加 bitbucket 私有存储库
问题描述
我的 gradle 项目已关闭,因为它对 bitbucket repo 有一些依赖,并且 bitbucket v1 api 已被弃用。
我在 Google 上搜索了很多关于如何迁移到 v2 的信息,但没有找到好的解决方案。
gradle 中的 v1 api 是这样的:
repositories {
maven {
credentials {
username "$mavenUser"
password "$mavenPassword"
}
url "https://api.bitbucket.org/1.0/repositories/<Team>/<repo>/raw/<branch>"
}
}
解决方案
repositories {
maven {
credentials {
username "$mavenUser"
password "$mavenPassword"
}
url "https://api.bitbucket.org/2.0/repositories/<Team>/<repo>/src/<branch>"
}
}
根据 v2 API 参考,我更新了 url,并且curl -u username:password https://api.bitbucket.org/2.0/repositories/<Team>/<repo>/src/<branch>/<path>
可以获取原始数据,但 gradle 仍然无法正常工作,并且总是从服务器收到状态代码 403:Forbidden
明确指定basic
身份验证后,gradle按预期工作
repositories {
maven {
credentials {
username "$mavenUser"
password "$mavenPassword"
}
authentication {
basic(BasicAuthentication)
}
url "https://api.bitbucket.org/2.0/repositories/<Team>/<repo>/src/<branch>"
}
}
下面是gradle文档
If no authentication schemes have been assigned to this repository, a default set of authentication schemes are used based on the repository's transport scheme.
推荐阅读
- javascript - Three.js 项目,在自上而下的视图中保持相机以对象为中心
- javascript - $(document).on(..) 事件有效,但 $("body").on(..) 对于动态生成的元素无效
- sql-server - SQL Server Migration Assistant for Access 如何确定聚集索引和非聚集索引?
- android - ViewPager 没有响应在 Fragment 中动态创建的布局区域中的触摸
- haproxy - Haporxy:如果服务器 1 关闭,则将连接重定向到第二台服务器;当服务器 2 宕机时到第 3 台服务器;
- php - 在葡萄牙语中将日期从长格式格式化为短格式
- bloom-filter - 只有一个输入哈希的布隆过滤器仍然是布隆过滤器吗?
- javascript - Jquery - 从下拉选择到上一个输入字段元素的值
- python - Python:从非常大的 JSON 请求中提取特定数据
- python - 如何使用现有的 unicode 字符转换字符串类型?