我的gradle项目已关闭,因为它对bitbucket存储库有一些依赖性,并且不建议使用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:禁止
在明确指定
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.