【发布时间】:2018-02-06 00:08:48
【问题描述】:
我正在尝试使用 gradle 和 ivy-publish 插件将 RPM 工件发布到 Artifactory 上的本地 YUM 存储库。我遇到的问题是发布任务似乎尝试上传工件两次,第二次尝试失败(正确),HTTP 状态代码为 403。我进行身份验证的工件用户具有部署/缓存权限但不删除.
我的问题是为什么发布任务会尝试两次上传工件?
我在下面包含了我的 gradle 配置和工件日志文件的摘录。请注意,RPM 是使用 netflix os-package 构建的
Gradle Config 发布配置:
apply plugin: "ivy-publish"
publishing {
publications {
rpm(IvyPublication) {
artifact buildRpm.outputs.getFiles().getSingleFile()
/* Ivy plugin forces an organisation to be set. Set it to anything
as the pattern layout later supresses it from appearing in the filename */
organisation 'dummy'
}
}
repositories {
ivy {
credentials {
username 'username'
password 'password'
}
url 'http://my.artifactory.com/artifactory/yum-dev-local/'
layout "pattern", {
artifact "${buildRpm.outputs.getFiles().getSingleFile().getName()}"
}
}
}
}
为了构建和发布工件,我执行以下操作(工件上有一个空的 yum-local repo)
./gradlew clean buildRpm publish
产生以下内容:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':my-artifact-service:publishRpmPublicationToIvyRepository'.
> Failed to publish publication 'rpm' to repository 'ivy'
> java.io.IOException: Could not PUT 'http://my.artifactory.com/artifactory/yum-dev-local/my-artifact-service-0.0.1-1.el7.x86_64.rpm'. Received status code 403 from server: Forbidden
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Artifactory 日志显示:
2016-10-12 15:41:41,828 [http-nio-8081-exec-92] [INFO ] (o.a.e.UploadServiceImpl:453) - Deploy to 'yum-dev-local:my-artifact-service-0.0.1-1.el7.x86_64.rpm' Content-Length: 4420
2016-10-12 15:41:41,842 [http-nio-8081-exec-64] [INFO ] (o.a.e.UploadServiceImpl:299) - Deploy to 'yum-dev-local:my-artifact-service-0.0.1-1.el7.x86_64.rpm.sha1' Content-Length: 40
2016-10-12 15:41:41,850 [http-nio-8081-exec-90] [WARN ] (o.a.r.ArtifactoryResponseBase:105) - Sending HTTP error code 403: Not enough permissions to overwrite artifact 'yum-dev-local:my-artifact-service-0.0.1-1.el7.x86_64.rpm' (user 'username' needs DELETE permission).
最后的日志行表明请求再次 PUT 工件。当我检查 repo 时,工件确实已成功上传,但是发布任务失败。有人能指出这里发生了什么吗?
版本:
------------------------------------------------------------
Gradle 2.14.1
------------------------------------------------------------
Build time: 2016-07-18 06:38:37 UTC
Revision: d9e2113d9fb05a5caabba61798bdb8dfdca83719
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_73 (Oracle Corporation 25.73-b02)
OS: Linux 4.3.5-300.fc23.x86_64 amd64
【问题讨论】:
-
您解决了这个问题吗?我也一样
-
与您的问题无关的评论。运行“gradle clean
”是一种反模式。可能这是您在使用 Maven 时学到的东西,对吧?与 Maven 不同,Gradle 在确定何时需要重建工件以及何时通过不重建工件可以节省时间方面非常好。如果您始终将“干净”应用为构建的一部分,那么您就会否定这一优势,并且构建速度会变慢。 -
@Jolta 感谢您的提示,是的,您说得对,这可能是我从使用 Maven 继承下来的习惯
标签: java gradle artifactory gradlew