簡體   English   中英

不允許用戶使用 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"

}

一些網站建議這是一個必須選中的復選框Any Build ,但我沒有找到它,我認為這可能是build.gradle文件的問題。

我究竟做錯了什么? 有沒有可能跳過構建描述符?

我在工件 gradle 文檔中發現,可以通過在默認部分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

“任何構建”復選框 Artifactory 權限頁面

“構建操作”“部署”復選框 Artifactory

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM