不允许用户使用 Gradle 将“.json”部署到 Artifactory 中

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"

}

一些网站建议这是一个必须选中的复选框 任何构建,但我没有找到它,我认为这可能是 [ 的问题=36=] 文件.

我做错了什么? 是否有可能完全跳过构建描述符?

我在 artifactory gradle documentation 中发现,可以通过在默认部分将 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