这是我的管道:
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 home的位置。运行官方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 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>
编辑:现在我认为该插件已完全损坏,我尝试通过正确的凭据将其全局传递给一个全局设置文件,并且 still 失败:
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
EDIT EDIT EDIT:继续我与这个胡扯的jfrog插件的史诗般的斗争,我在本地存储库上禁用了一致性检查,它可以部署,但是现在我明白了这个错误。它转换了我的pom并将1.0-SNAPSHOT
变成1.0-20191018.195756-35
的原因,为什么要这样做以及如何使其不破坏我的pom文件?
编辑编辑编辑编辑:
我一定是个笨蛋,或者文档不是很清楚(也许两者都有)。我之所以使用部署目标,是因为...我想进行部署。但显然您不使用插件执行此操作-现在对我来说这很有意义。您clean
和install
软件包,但将其留给插件进行部署,以便将其放置在正确的位置并附加构建信息。以install
为目标
答案 0 :(得分:1)
答案是不使用deploy
目标。构建软件包,插件将负责部署部分