opt*_*lic 5 artifactory gradle
我已经使用 gradle 设置了用于发布到artifactory 的用户名和密码,但是,构建在发布build.info 时失败。
artifactory {
publish {
contextUrl = 'http://localhost:8081/artifactory'
repository {
repoKey = "libs-snapshot-local"
username = "user"
password = "pass"
maven = true
}
defaults {
publications = ('mavenJava')
}
}
}
Run Code Online (Sandbox Code Playgroud)
我运行 gradle 的用户无权访问神器存储库,但神器块中的用户可以访问。
似乎build.info是使用 gradle 用户而不是 build.gradle 中的用户将其发布到神器。
如何设置用户名/密码以便build.info使用具有权限的用户发布?
您可以为Gradle Artifactory 插件配置两组 Artifactory 凭据:
用于解决工件的凭证
repositories {
jcenter()
maven {
url "http://repo.myorg.com/artifactory/my-repo" // The Artifactory (preferably virtual) repository to resolve from
credentials { // Optional resolver credentials (leave out to use anonymous resolution)
username = "username" // Artifactory user name
password = "password" // Password or API Key
}
}
}
Run Code Online (Sandbox Code Playgroud)
用于部署工件和发布构建信息的凭据。这是您在 Artifactory 中部署工件和构建信息所需的一组凭据。
您需要确保该用户具有存储库:部署和构建:部署的权限。
运行 gradle 的操作系统用户(gradle 用户)未用于身份验证,并且不被识别为 Artifactory 用户。然而,它被捕获为构建信息的一部分。
artifactory {
contextUrl = 'http://repo.myorg.com/artifactory' // The base Artifactory URL if not overridden by the publisher/resolver
publish {
contextUrl = 'http://repo.myorg.com/artifactory' //The base Artifactory URL for the publisher
//A closure defining publishing information
repository {
repoKey = 'my-repo' //The Artifactory repository key to publish to
username = 'stackoverflow' //The publisher user name
password = 'password' //The publisher password or API key
}
}
}
Run Code Online (Sandbox Code Playgroud)
预期的行为是运行以下命令时
./gradlew clean artifactoryPublish
Run Code Online (Sandbox Code Playgroud)
构建工件和构建信息将部署到 Artifactory
[pool-17-thread-1] Deploying artifact: http://127.0.0.1:8081/artifactory/libs-snapshot-local/gradle-example-minimal/1.0-SNAPSHOT/gradle-example-minimal-1.0-SNAPSHOT.jar
[pool-17-thread-1] Deploying artifact: http://127.0.0.1:8081/artifactory/libs-snapshot-local/gradle-example-minimal/1.0-SNAPSHOT/gradle-example-minimal-1.0-SNAPSHOT.pom
> Task :artifactoryDeploy
Deploying build descriptor to: http://127.0.0.1:8081/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under http://127.0.0.1:8081/artifactory/webapp/builds/gradle-example-minimal/1602276439713
BUILD SUCCESSFUL in 903ms
7 actionable tasks: 7 executed
Run Code Online (Sandbox Code Playgroud)
在 Artifactory 中,您将看到使用发布部分中指定的用户名部署的工件
以及构建信息 JSON 文件
在构建信息中,您将看到正在捕获 2 种用户类型:
| 归档时间: |
|
| 查看次数: |
11697 次 |
| 最近记录: |