rtMavenRun() Artifactory 插件不使用在 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) 上配置了 creds 和 URL。我知道它配置正确,因为 rtPublishBuildInfo() 工作并发布到 Artifactory。它使用的用户是完全管理员,因此应该没有权限问题。
这是容器从属中的 运行,因此我必须手动设置环境以指向 Maven 和 Java 主目录的位置,以便插件找到它。这是 运行 官方 Maven 镜像
当我尝试部署目标(确认使用相同的用户凭据在本地工作)时,我看到了这个错误:
[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 输出。好像没有用我的信用?这个插件如何与我在配置中设置的 Jenkins cred 绑定一起工作?它如何将这些信用传递给 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>
编辑 1
现在我认为这个插件完全坏了我试着用正确的信用明确地传递给它一个全局设置文件但是它仍然失败:
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]
编辑 2
好的,尽管这在本地运行良好,但我尝试在我的 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
编辑 3
继续我与这个 crap-ass jfrog 插件的史诗般的斗争我禁用了对本地存储库的一致性检查并且它可以部署但现在我明白了那个错误。它正在转换我的 pom 并将 1.0-SNAPSHOT
变成 1.0-20191018.195756-35
为什么要这样做以及如何让它不破坏我的 pom 文件?
编辑 4
我一定是个白痴,或者文档不是很清楚(也许两者都有)。我使用 deploy 目标是因为我想部署。但显然你不会用插件来做到这一点——这对我来说很有意义。您 clean
和 install
包,但将其留给插件进行部署,以便将其放在正确的位置并附加构建信息。使用 install
作为目标有效。
答案是不要使用 deploy
目标。构建包,插件将负责部署部分
这是我的管道:
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) 上配置了 creds 和 URL。我知道它配置正确,因为 rtPublishBuildInfo() 工作并发布到 Artifactory。它使用的用户是完全管理员,因此应该没有权限问题。
这是容器从属中的 运行,因此我必须手动设置环境以指向 Maven 和 Java 主目录的位置,以便插件找到它。这是 运行 官方 Maven 镜像
当我尝试部署目标(确认使用相同的用户凭据在本地工作)时,我看到了这个错误:
[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 输出。好像没有用我的信用?这个插件如何与我在配置中设置的 Jenkins cred 绑定一起工作?它如何将这些信用传递给 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>
编辑 1
现在我认为这个插件完全坏了我试着用正确的信用明确地传递给它一个全局设置文件但是它仍然失败:
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]
编辑 2
好的,尽管这在本地运行良好,但我尝试在我的 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
编辑 3
继续我与这个 crap-ass jfrog 插件的史诗般的斗争我禁用了对本地存储库的一致性检查并且它可以部署但现在我明白了那个错误。它正在转换我的 pom 并将 1.0-SNAPSHOT
变成 1.0-20191018.195756-35
为什么要这样做以及如何让它不破坏我的 pom 文件?
编辑 4
我一定是个白痴,或者文档不是很清楚(也许两者都有)。我使用 deploy 目标是因为我想部署。但显然你不会用插件来做到这一点——这对我来说很有意义。您 clean
和 install
包,但将其留给插件进行部署,以便将其放在正确的位置并附加构建信息。使用 install
作为目标有效。
答案是不要使用 deploy
目标。构建包,插件将负责部署部分