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

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

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

问题

以下是翻译好的部分:

我正在尝试使用Gradle将项目的JAR文件部署到JFrog Artifactory。build.gradle文件如下(部分内容适用于部署):

  1. buildscript {
  2. repositories {
  3. jcenter()
  4. }
  5. dependencies {
  6. classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.16.1"
  7. }
  8. configurations.classpath {
  9. resolutionStrategy {
  10. cacheDynamicVersionsFor 0, 'seconds'
  11. cacheChangingModulesFor 0, 'seconds'
  12. }
  13. }
  14. }
  15. plugins {
  16. id 'java'
  17. id 'com.jfrog.artifactory' version '4.16.1'
  18. id 'maven-publish'
  19. }
  20. repositories {
  21. mavenCentral()
  22. mavenLocal()
  23. repositories {
  24. mavenCentral()
  25. maven {
  26. url "<artifactoryPath>/artifactory/gcc-maven/"
  27. credentials {
  28. username = "${artifactory_user}"
  29. password = "${artifactory_password}"
  30. }
  31. }
  32. }
  33. }
  34. publishing {
  35. publications {
  36. mavenJava(MavenPublication) {
  37. groupId group
  38. version version
  39. from components.java
  40. }
  41. }
  42. }
  43. artifactory {
  44. contextUrl = "${artifactory_contextUrl}"
  45. publish {
  46. repository {
  47. repoKey = 'gcc-maven-local'
  48. username = "${artifactory_user}"
  49. password = "${artifactory_password}"
  50. maven = true
  51. }
  52. defaults {
  53. publications('mavenJava')
  54. publishArtifacts = true
  55. properties = ['version': version, 'dev.team': '<project>']
  56. publishPom = true
  57. }
  58. }
  59. resolve {
  60. repository {
  61. repoKey = 'gcc-maven'
  62. username = "${artifactory_user}"
  63. password = "${artifactory_password}"
  64. maven = true
  65. }
  66. }
  67. }

当我使用用户名和密码时,一切正常,但当我使用令牌时,.jar.module和*.pom*文件被推送,但构建描述符没有被推送。我遇到了以下错误:

  1. > Task :artifactoryDeploy
  2. Deploying build descriptor to: <artifactoryPath>/artifactory/api/build
  3. Could not build the build-info object.
  4. java.io.IOException: Failed to send build descriptor. 403 Response message: {
  5. "errors" : [ {
  6. "status" : 403,
  7. "message" : "User token:fim-artifactory-gcc-maven-rw-token is not permitted to deploy '<name>.json' into '<name>.json'."
  8. } ]
  9. }

令牌看起来像这样:

  1. {
  2. "scope" : "member-of-groups:fim-artifactory-gcc-maven api:*",
  3. "access_token" : "<very_long_string>",
  4. "expires_in" : 0,
  5. "token_type" : "Bearer"
  6. }

一些网站建议勾选“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):

  1. buildscript {
  2. repositories {
  3. jcenter()
  4. }
  5. dependencies {
  6. classpath &quot;org.jfrog.buildinfo:build-info-extractor-gradle:4.16.1&quot;
  7. }
  8. configurations.classpath {
  9. resolutionStrategy {
  10. cacheDynamicVersionsFor 0, &#39;seconds&#39;
  11. cacheChangingModulesFor 0, &#39;seconds&#39;
  12. }
  13. }
  14. }
  15. plugins {
  16. id &#39;java&#39;
  17. id &#39;com.jfrog.artifactory&#39; version &#39;4.16.1&#39;
  18. id &#39;maven-publish&#39;
  19. }
  20. repositories {
  21. mavenCentral()
  22. mavenLocal()
  23. repositories {
  24. mavenCentral()
  25. maven {
  26. url &quot;&lt;artifactoryPath&gt;/artifactory/gcc-maven/&quot;
  27. credentials {
  28. username = &quot;${artifactory_user}&quot;
  29. password = &quot;${artifactory_password}&quot;
  30. }
  31. }
  32. }
  33. publishing {
  34. publications {
  35. mavenJava(MavenPublication) {
  36. groupId group
  37. version version
  38. from components.java
  39. }
  40. }
  41. }
  42. artifactory {
  43. contextUrl = &quot;${artifactory_contextUrl}&quot;
  44. publish {
  45. repository {
  46. repoKey = &#39;gcc-maven-local&#39;
  47. username = &quot;${artifactory_user}&quot;
  48. password = &quot;${artifactory_password}&quot;
  49. maven = true
  50. }
  51. defaults {
  52. publications(&#39;mavenJava&#39;)
  53. publishArtifacts = true
  54. properties = [&#39;version&#39;: version, &#39;dev.team&#39;: &#39;&lt;project&gt;&#39;]
  55. publishPom = true
  56. }
  57. }
  58. resolve {
  59. repository {
  60. repoKey = &#39;gcc-maven&#39;
  61. username = &quot;${artifactory_user}&quot;
  62. password = &quot;${artifactory_password}&quot;
  63. maven = true
  64. }
  65. }
  66. }

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:

  1. &gt; Task :artifactoryDeploy
  2. Deploying build descriptor to: &lt;artifactoryPath&gt;/artifactory/api/build
  3. Could not build the build-info object.
  4. java.io.IOException: Failed to send build descriptor. 403 Response message: {
  5. &quot;errors&quot; : [ {
  6. &quot;status&quot; : 403,
  7. &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;
  8. } ]
  9. }

The token looks like this:

  1. {
  2. &quot;scope&quot; : &quot;member-of-groups:fim-artifactory-gcc-maven api:*&quot;,
  3. &quot;access_token&quot; : &quot;&lt;very_long_string&gt;&quot;,
  4. &quot;expires_in&quot; : 0,
  5. &quot;token_type&quot; : &quot;Bearer&quot;
  6. }

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解决了该问题。

  1. artifactory {
  2. contextUrl = "${artifactory_contextUrl}"
  3. publish {
  4. repository {
  5. repoKey = 'libs-local'
  6. username = "${artifactory_user}"
  7. password = "${artifactory_password}"
  8. maven = true
  9. }
  10. defaults {
  11. publishBuildInfo = false
  12. publications ('mavenJava')
  13. }
  14. }
  15. }
英文:

I was also getting the same issue on Jfrog and setting publishBuildInfo = false solved the issue

  1. artifactory {
  2. contextUrl = &quot;${artifactory_contextUrl}&quot;
  3. publish {
  4. repository {
  5. repoKey = &#39;libs-local&#39;
  6. username = &quot;${artifactory_user}&quot;
  7. password = &quot;${artifactory_password}&quot;
  8. maven = true
  9. }
  10. defaults {
  11. publishBuildInfo = false
  12. publications (&#39;mavenJava&#39;)
  13. }
  14. }
  15. }

答案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:

确定