User is not permitted to deploy ‘.json’ into Artifactory Using Gradle.

huangapple go评论72阅读模式
英文:

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 &quot;org.jfrog.buildinfo:build-info-extractor-gradle:4.16.1&quot;
}
configurations.classpath {
resolutionStrategy {
cacheDynamicVersionsFor 0, &#39;seconds&#39;
cacheChangingModulesFor 0, &#39;seconds&#39;
}
}
}
plugins {
id &#39;java&#39;
id &#39;com.jfrog.artifactory&#39; version &#39;4.16.1&#39;
id &#39;maven-publish&#39;
}
repositories {
mavenCentral()
mavenLocal()
repositories {
mavenCentral()
maven {
url &quot;&lt;artifactoryPath&gt;/artifactory/gcc-maven/&quot;
credentials {
username = &quot;${artifactory_user}&quot;
password = &quot;${artifactory_password}&quot;
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId group
version version
from components.java
}
}
}
artifactory {
contextUrl = &quot;${artifactory_contextUrl}&quot;
publish {
repository {
repoKey = &#39;gcc-maven-local&#39;
username = &quot;${artifactory_user}&quot;
password = &quot;${artifactory_password}&quot;
maven = true
}
defaults {
publications(&#39;mavenJava&#39;)
publishArtifacts = true
properties = [&#39;version&#39;: version, &#39;dev.team&#39;: &#39;&lt;project&gt;&#39;]
publishPom = true
}
}
resolve {
repository {
repoKey = &#39;gcc-maven&#39;
username = &quot;${artifactory_user}&quot;
password = &quot;${artifactory_password}&quot;
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:

&gt; Task :artifactoryDeploy
Deploying build descriptor to: &lt;artifactoryPath&gt;/artifactory/api/build
Could not build the build-info object.
java.io.IOException: Failed to send build descriptor. 403 Response message: {
&quot;errors&quot; : [ {
&quot;status&quot; : 403,
&quot;message&quot; : &quot;User token:fim-artifactory-gcc-maven-rw-token is not permitted to deploy &#39;&lt;name&gt;.json&#39; into &#39;&lt;name&gt;.json&#39;.&quot;
} ]
}

The token looks like this:

{
&quot;scope&quot; : &quot;member-of-groups:fim-artifactory-gcc-maven api:*&quot;,
&quot;access_token&quot; : &quot;&lt;very_long_string&gt;&quot;,
&quot;expires_in&quot; : 0,
&quot;token_type&quot; : &quot;Bearer&quot;
}

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 = &quot;${artifactory_contextUrl}&quot;
publish {
repository {
repoKey = &#39;libs-local&#39;
username = &quot;${artifactory_user}&quot;
password = &quot;${artifactory_password}&quot;
maven = true
}
defaults {
publishBuildInfo = false
publications (&#39;mavenJava&#39;)
}
}
}

答案3

得分: 2

以下是已翻译的内容:

作为跳过构建信息发布的替代方法,请参考此 GitHub 问题中的截图,以了解如何启用所需的权限:

https://github.com/jfrog/jenkins-artifactory-plugin/issues/120

User is not permitted to deploy ‘.json’ into Artifactory Using Gradle.

User is not permitted to deploy ‘.json’ into Artifactory Using Gradle.

英文:

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

User is not permitted to deploy ‘.json’ into Artifactory Using Gradle.

User is not permitted to deploy ‘.json’ into Artifactory Using Gradle.

huangapple
  • 本文由 发表于 2020年7月31日 23:34:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/63194867.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定