簡體   English   中英

rtMavenRun() 工件插件未使用 jenkins 中配置的憑據

[英]rtMavenRun() artifactory plugin not using credentials configured in jenkins

這是我的管道:

stage('Deploy') {
    environment {
        MAVEN_HOME = '/usr/share/maven'
        JAVA_HOME= '/usr/local/openjdk-8'
    }
    steps {
        rtMavenResolver (
                id: 'resolver-unique-id',
                serverId: 'my-server-config',
                releaseRepo: 'my-repo',
                snapshotRepo: 'my-repo'
        )
        rtMavenDeployer (
                id: 'deployer-unique-id',
                serverId: 'my-server-config',
                releaseRepo: 'my-repo',
                snapshotRepo: 'my-repo'
        )
        rtMavenRun (
                pom: 'pom.xml',
                goals: 'help:effective-settings',
                //goals: 'deploy',
                resolverId: 'resolver-unique-id',
                deployerId: 'deployer-unique-id'
        )

        // This works
        rtPublishBuildInfo (
            serverId: 'my-server-config'
        )

我在 jenkins(my-server-config)上配置了憑據和 URL。 我知道它的配置正確,因為 rtPublishBuildInfo() 工作並發布到工件。 它使用的用戶是一個完整的管理員,所以應該沒有權限問題。

這是在容器從屬設備中運行的,因此我必須手動設置環境以指向 maven 和 java 主頁的位置,以便插件找到它。 它運行官方的 mavenn 圖像

當我嘗試部署目標(確認使用相同的用戶憑據在本地工作)時,我看到此錯誤:

[main] WARNING org.codehaus.plexus.PlexusContainer - Could not transfer metadata com.mycompany.app:my-app:1.0-SNAPSHOT/maven-metadata.xml from/to snapshots (https://my-tenant.jfrog.io/my-tenant/my-repo): Not authorized

我嘗試運行help:effective-settings目標並檢查了 jenkins output。 看起來它沒有使用我的信譽? 這個插件如何與我在配置中設置的 jenkins 憑據綁定一起使用? 它如何將這些信譽傳遞給 mvn?

Effective user-specific configuration settings:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Generated by Maven Help Plugin on 2019-10-18T19:04:34Z                 -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/                -->
<!--                                                                        -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Effective Settings for 'root' on 'mypackagepackage-2zbtg-hsxqv'   -->
<!--                                                                        -->
<!-- ====================================================================== -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <localRepository>/root/.m2/repository</localRepository>
  <pluginGroups>
    <pluginGroup>org.apache.maven.plugins</pluginGroup>
    <pluginGroup>org.codehaus.mojo</pluginGroup>
  </pluginGroups>
</settings>

編輯:現在我認為插件完全壞了我嘗試明確地向它傳遞一個具有正確憑據的全局設置文件,但它仍然失敗:

rtMavenRun (
        pom: 'pom.xml',
        //global-settings here is a jenkins secret file with the entire contents of a global settings.xml
        goals: '--settings ${global-settings} deploy',
        resolverId: 'resolver-unique-id',
        deployerId: 'deployer-unique-id'
)

我看到這個錯誤:

[main] ERROR org.apache.maven.cli.MavenCli - Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project my-app: Execution default-deploy of goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy failed.: NullPointerException -> [Help 1]

編輯編輯:好的,即使這在本地工作正常,我也嘗試在我的 pom 中設置部署插件的更新版本:

  <plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
  </plugin>

現在我從插件中得到另一個錯誤(這仍然可以在本地正常工作):

Caused by: java.io.IOException: Failed to deploy file. Status code: 409 Response message: Artifactory returned the following errors: 
The target deployment path 'com/mycompany/app/my-app/1.0-20191018.195756-35/my-app-1.0-20191018.195756-35.pom' does not match the POM's expected path prefix 'com/mycompany/app/my-app/1.0-SNAPSHOT'. Please verify your POM content for correctness and make sure the source path is a valid Maven repository root path. Status code: 40

編輯 編輯 編輯:繼續我與這個垃圾 jfrog 插件的史詩般的斗爭,我禁用了本地 repo 的一致性檢查,它可以部署,但現在我明白了這個錯誤。 它轉換了我的 pom 並將1.0-SNAPSHOT轉換為1.0-20191018.195756-35為什么要這樣做以及如何讓它不破壞我的 pom 文件?

編輯 編輯 編輯 編輯:我一定是個白痴或文檔不是很清楚(可能兩者兼而有之)。 我使用部署目標是因為...我想部署。 但顯然你不用插件來做這件事——現在這對我來說很有意義。 cleaninstall package,但將其留給插件進行部署,以便將其放置在正確的位置並附加構建信息。 使用install作為目標有效

答案是不要使用deploy目標。 構建 package 插件將負責部署部分

暫無
暫無

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

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