简体   繁体   English

rtMavenRun() 工件插件未使用 jenkins 中配置的凭据

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

This is my pipeline:这是我的管道:

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'
        )

I have the creds and URL configured on jenkins (my-server-config).我在 jenkins(my-server-config)上配置了凭据和 URL。 I know its configured correctly because rtPublishBuildInfo() works and publishes to artifactory.我知道它的配置正确,因为 rtPublishBuildInfo() 工作并发布到工件。 The user its using is a full admin so should be no perms issues.它使用的用户是一个完整的管理员,所以应该没有权限问题。

This is running in a container slave so I had to manually set environment to point to the locations of maven and java home for the plugin to find it.这是在容器从属设备中运行的,因此我必须手动设置环境以指向 maven 和 java 主页的位置,以便插件找到它。 Its running the official mavenn image它运行官方的 mavenn 图像

When I try the deploy goal (confirmed working locally with same user creds) I see this error:当我尝试部署目标(确认使用相同的用户凭据在本地工作)时,我看到此错误:

[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

I tried running the help:effective-settings goal and checked jenkins output.我尝试运行help:effective-settings目标并检查了 jenkins output。 It looks like its not using my creds?看起来它没有使用我的信誉? How does this plugin even work with the jenkins cred binding I set in the config?这个插件如何与我在配置中设置的 jenkins 凭据绑定一起使用? How does it pass those creds to mvn?它如何将这些信誉传递给 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>

Edit: now i think the plugin is totally broken I tried explicitly passing it a global settings file with the right creds and its still failing:编辑:现在我认为插件完全坏了我尝试明确地向它传递一个具有正确凭据的全局设置文件,但它仍然失败:

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'
)

Im seeing this error:我看到这个错误:

[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]

EDIT EDIT: OK so even though this works fine locally I tried setting an updated version of the deployment plugin in my pom:编辑编辑:好的,即使这在本地工作正常,我也尝试在我的 pom 中设置部署插件的更新版本:

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

And now Im getting another error from the plugin (this still works locally without issue):现在我从插件中得到另一个错误(这仍然可以在本地正常工作):

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

EDIT EDIT EDIT: Continuing my epic struggle with this crap-ass jfrog plugin I disabled consistency checks on the local repo and it can deploy but now I understand that error.编辑 编辑 编辑:继续我与这个垃圾 jfrog 插件的史诗般的斗争,我禁用了本地 repo 的一致性检查,它可以部署,但现在我明白了这个错误。 Its transforming my pom and turning 1.0-SNAPSHOT into 1.0-20191018.195756-35 why is it doing that and how to a get it to not mangle my pom file?它转换了我的 pom 并将1.0-SNAPSHOT转换为1.0-20191018.195756-35为什么要这样做以及如何让它不破坏我的 pom 文件?

EDIT EDIT EDIT EDIT: I must be a moron or documentation is not very clear (maybe both).编辑 编辑 编辑 编辑:我一定是个白痴或文档不是很清楚(可能两者兼而有之)。 I was using the deploy goal because... i wanted to deploy.我使用部署目标是因为...我想部署。 But apparently you dont do that with the plugin- this makes sense to me now.但显然你不用插件来做这件事——现在这对我来说很有意义。 you clean and install the package but leave it to the plugin to deploy it so it puts it in the right location and attaches build info.cleaninstall package,但将其留给插件进行部署,以便将其放置在正确的位置并附加构建信息。 using install as a goal works使用install作为目标有效

Answer is dont use deploy goal.答案是不要使用deploy目标。 build the package and the plugin will take care of the deployment part构建 package 插件将负责部署部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Artifactory插件和Credentials插件将Jenven的Maven工件部署到Artifactory时解决401失败? - How can I resolve a 401 failure when deploying a Maven artifact from Jenkins to Artifactory using the Artifactory Plugin and the Credentials Plugin? 如何将 -X 和 -B 等命令行参数传递给 Artifactory Maven 插件中的 rtMavenRun? - How to pass command line parameters like -X and -B to rtMavenRun in Artifactory Maven Plugin? 使用 Artifactory 插件“包含模式”从 Jenkins 发布项目文件 - Publish project files from Jenkins using Artifactory plugin "Include Patterns" 使用Artifactory Jenkins插件从嵌套项目中部署工件 - Deploying artifacts from nested projects using Artifactory Jenkins plugin Jenkins Artifactory插件不生成POM文件 - Jenkins Artifactory plugin not generating POM file 如何使用jenkins将grails二进制插件部署到工件上? - How to deploy a grails binary plugin to artifactory with jenkins? Jenkins Artifactory Plugin多项目发行 - Jenkins Artifactory Plugin multi-project release 使用Jenkins管道推送到Artifactory - Pushing to Artifactory using Jenkins pipeline 使Artifactory插件与Jenkins和Maven一起使用 - Getting Artifactory Plugin to work with Jenkins and Maven Jenkins Artifactory插件忽略了Maven UniqueVersion - Jenkins Artifactory Plugin ignoring Maven UniqueVersion
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM