[英]How to Publish (deploy) local (.war .jar) files to Artifactory using Gradle version 1.12?
[英]User is not permitted to deploy '.json' into Artifactory Using Gradle
我正在尝试使用 gradle 将项目 jar 部署到 JFrog Artifactory 中。 build.gradle
文件如下所示(部署所需的部分):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.16.1"
}
configurations.classpath {
resolutionStrategy {
cacheDynamicVersionsFor 0, 'seconds'
cacheChangingModulesFor 0, 'seconds'
}
}
}
plugins {
id 'java'
id 'com.jfrog.artifactory' version '4.16.1'
id 'maven-publish'
}
repositories {
mavenCentral()
mavenLocal()
repositories {
mavenCentral()
maven {
url "<artifactoryPath>/artifactory/gcc-maven/"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId group
version version
from components.java
}
}
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'gcc-maven-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications('mavenJava')
publishArtifacts = true
properties = ['version': version, 'dev.team': '<project>']
publishPom = true
}
}
resolve {
repository {
repoKey = 'gcc-maven'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
当我使用我的用户名和密码时,一切正常,但是当我使用令牌时,会推送 .jar .module和.pom文件,但不会推送构建描述符。 我有下一个错误:
> Task :artifactoryDeploy
Deploying build descriptor to: <artifactoryPath>/artifactory/api/build
Could not build the build-info object.
java.io.IOException: Failed to send build descriptor. 403 Response message: {
"errors" : [ {
"status" : 403,
"message" : "User token:fim-artifactory-gcc-maven-rw-token is not permitted to deploy '<name>.json' into '<name>.json'."
} ]
}
令牌如下所示:
{
"scope" : "member-of-groups:fim-artifactory-gcc-maven api:*",
"access_token" : "<very_long_string>",
"expires_in" : 0,
"token_type" : "Bearer"
}
一些网站建议这是一个必须选中的复选框Any Build ,但我没有找到它,我认为这可能是build.gradle文件的问题。
我究竟做错了什么? 有没有可能跳过构建描述符?
我在工件 gradle 文档中发现,可以通过在默认部分publishBuildInfo
设置为false
来忽略构建描述符。 就我而言,这就是我要寻找的东西。
我在 Jfrog 上也遇到了同样的问题,设置 publishBuildInfo = false 解决了这个问题
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'libs-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publishBuildInfo = false
publications ('mavenJava')
}
}
}
作为跳过发布构建信息的替代方法,请参阅此 GitHub 问题的屏幕截图,以获取有关启用所需权限的参考:
https://github.com/jfrog/jenkins-artifactory-plugin/issues/120
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.