是否可以通过 SSH (Gradle) 编译 bitbucket 依赖项?
Is it possible to compile bitbucket dependency via SSH (Gradle)?
好的,我正在尝试编译对远程 Maven url (bitbucket) 的依赖。问题是我无法在那个阶段通过 bitbucket 身份验证。
我试过这个:
repositories{
maven{ url "https:" + "${username}" + ":" + "${password}" + ...etc}
}
而且它对我不起作用。所以我已经启用并通过 SSH 连接。问题是:如何使用 SSH 从远程私有 Maven 存储库(托管在 bitbucket 上)编译依赖项?
来自dependency management section of the gradle documentation:
repositories {
maven {
url "sftp://repo.mycompany.com:22/maven2"
credentials {
username 'user'
password 'password'
}
}
}
我的团队面临着完全相同的问题,我们最终使用 bitbucket REST API 解决了它。
所以把下面的代码放在build.gradle文件中(在项目根目录)
allprojects {
repositories {
maven {
url 'https://api.bitbucket.org/1.0/repositories/REPO_OWNER/REPO_NAME/raw/BRANCH_NAME'
}
credentials {
username bitbucket_username
password bitbucket_password
}
}
}
其中 REPO_OWNER 是您的 bitbucket 用户名或拥有 repo 的团队名称,REPO_NAME正如您已经知道的那样,您想要从中获取库的存储库名称和 BRANCH_NAME 分支名称。
此外 bitbucket_username 和 bitbucket_password 定义在 gradle.properties 中以下方式:
bitbucket_username = yourBitbucketUsername
bitbucket_password = yourBitbucketPasword
请注意用户名和密码没有任何引号。
希望对你有用!
好的,我正在尝试编译对远程 Maven url (bitbucket) 的依赖。问题是我无法在那个阶段通过 bitbucket 身份验证。 我试过这个:
repositories{
maven{ url "https:" + "${username}" + ":" + "${password}" + ...etc}
}
而且它对我不起作用。所以我已经启用并通过 SSH 连接。问题是:如何使用 SSH 从远程私有 Maven 存储库(托管在 bitbucket 上)编译依赖项?
来自dependency management section of the gradle documentation:
repositories {
maven {
url "sftp://repo.mycompany.com:22/maven2"
credentials {
username 'user'
password 'password'
}
}
}
我的团队面临着完全相同的问题,我们最终使用 bitbucket REST API 解决了它。 所以把下面的代码放在build.gradle文件中(在项目根目录)
allprojects {
repositories {
maven {
url 'https://api.bitbucket.org/1.0/repositories/REPO_OWNER/REPO_NAME/raw/BRANCH_NAME'
}
credentials {
username bitbucket_username
password bitbucket_password
}
}
}
其中 REPO_OWNER 是您的 bitbucket 用户名或拥有 repo 的团队名称,REPO_NAME正如您已经知道的那样,您想要从中获取库的存储库名称和 BRANCH_NAME 分支名称。
此外 bitbucket_username 和 bitbucket_password 定义在 gradle.properties 中以下方式:
bitbucket_username = yourBitbucketUsername
bitbucket_password = yourBitbucketPasword
请注意用户名和密码没有任何引号。
希望对你有用!