繁体   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