【问题标题】:User is not permitted to deploy '.json' into Artifactory Using Gradle不允许用户使用 Gradle 将“.json”部署到 Artifactory
【发布时间】:2020-11-21 11:30:30
【问题描述】:

我正在尝试使用 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 文件的问题.

我做错了什么? 有没有可能跳过构建描述符?

【问题讨论】:

    标签: java gradle jar artifactory


    【解决方案1】:

    我在artifactory gradle documentation 中发现可以通过在默认部分中将publishBuildInfo 设置为false 来忽略构建描述符。就我而言,这正是我所寻找的。​​p>

    【讨论】:

    【解决方案2】:

    我在 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')
            }
        }
    }
    

    【讨论】:

    【解决方案3】:

    作为跳过发布构建信息的替代方法,请参阅此 GitHub 问题上的屏幕截图,以获取有关启用所需权限的参考:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-17
      • 2019-03-26
      • 2015-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多