英文:
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文件有关。我做错了什么?是否有可能完全跳过构建描述符?
希望这对您有所帮助。
英文:
I am trying to deploy a project jar into JFrog Artifactory using gradle. The build.gradle
file looks like this (the part necessary for deploy):
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
}
}
}
When I use my username and password everything works fine but when I use a token the .jar .module and .pom files are pushed but not the build descriptor. I have the next error:
> 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'."
} ]
}
The token looks like this:
{
"scope" : "member-of-groups:fim-artifactory-gcc-maven api:*",
"access_token" : "<very_long_string>",
"expires_in" : 0,
"token_type" : "Bearer"
}
Some sites suggest that is a checkbox Any Build that must be checked but I don't find it and I think it might be a problem with build.gradle file.
What am I doing wrong?
It's there any possibility to skip the build descriptor at all?
答案1
得分: 8
我在artifactory gradle documentation中发现,可以通过在默认部分将publishBuildInfo
设置为false
来忽略构建描述符。在我的情况下,这正是我要找的。
英文:
I found out in artifactory gradle documentation that build descriptor can be ignored by setting publishBuildInfo
to false
in the defaults section. In my case it was what I was looking for.
答案2
得分: 4
我也在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')
}
}
}
英文:
I was also getting the same issue on Jfrog and setting publishBuildInfo = false solved the issue
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'libs-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publishBuildInfo = false
publications ('mavenJava')
}
}
}
答案3
得分: 2
以下是已翻译的内容:
作为跳过构建信息发布的替代方法,请参考此 GitHub 问题中的截图,以了解如何启用所需的权限:
https://github.com/jfrog/jenkins-artifactory-plugin/issues/120
英文:
As an alternative to skipping publishing of build info, see the screenshots on this GitHub issue for reference on enabling the required permissions:
https://github.com/jfrog/jenkins-artifactory-plugin/issues/120
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论