[英]User is not permitted to deploy '.json' into Artifactory Using Gradle
I am trying to deploy a project jar into JFrog Artifactory using gradle.我正在尝试使用 gradle 将项目 jar 部署到 JFrog Artifactory 中。 The
build.gradle
file looks like this (the part necessary for deploy): 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
}
}
}
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.当我使用我的用户名和密码时,一切正常,但是当我使用令牌时,会推送 .jar .module和.pom文件,但不会推送构建描述符。 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.一些网站建议这是一个必须选中的复选框Any Build ,但我没有找到它,我认为这可能是build.gradle文件的问题。
What am I doing wrong?我究竟做错了什么? It's there any possibility to skip the build descriptor at all?
有没有可能跳过构建描述符?
I found out in artifactory gradle documentation that build descriptor can be ignored by setting publishBuildInfo
to false
in the defaults section.我在工件 gradle 文档中发现,可以通过在默认部分
publishBuildInfo
设置为false
来忽略构建描述符。 In my case it was what I was looking for.就我而言,这就是我要寻找的东西。
I was also getting the same issue on Jfrog and setting publishBuildInfo = false solved the issue我在 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')
}
}
}
As an alternative to skipping publishing of build info, see the screenshots on this GitHub issue for reference on enabling the required permissions:作为跳过发布构建信息的替代方法,请参阅此 GitHub 问题的屏幕截图,以获取有关启用所需权限的参考:
https://github.com/jfrog/jenkins-artifactory-plugin/issues/120 https://github.com/jfrog/jenkins-artifactory-plugin/issues/120
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.