【发布时间】:2017-06-16 09:06:17
【问题描述】:
问题
Maven 解释:
versions:update-parent -N -DallowSnapshots=true -DparentVersion=[1.8.0,1.9.0)
作为:
versions:update-parent -N -DallowSnapshots=true '-DparentVersion=[1.8.0' '1.9.0)'
我正在尝试像这样在 Jenkinsfile 管道中运行 Maven(为可读性添加了换行符,这都在一行上):
sh "mvn release:clean release:prepare -X
-DcheckModificationExcludeList=pom.xml,pom.xml.versionsBackup
-Dresume=false
-DpreparationGoals=\'clean install -Dmaven.test.failure.ignore=true'
-Darguments=\'-Dbuild.phase.beforeDeploy -DskipTests=true\'
-DcompletionGoals=\'versions:update-parent -N -DallowSnapshots=true -DparentVersion=[1.8.0,1.9.0)\'
-DtagNameFormat=@{project.groupId}-@{project.artifactId}-@{project.version}"
当 Maven 开始执行完成目标部分时,它会拆分版本范围,将其视为 2 个单独的参数并以错误退出。相关日志片段:
[INFO] Executing goals 'versions:update-parent -N -DallowSnapshots=true -DparentVersion=[1.8.0,1.9.0)'...
[DEBUG] Using ${maven.home} of: '/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/mvn-3.2.5'.
[DEBUG] Executing: /bin/sh -c cd /home/jenkins/workspace/ife-jen-maven-runner_master-6CIUKZ3STQA5HR4E2RYGZ5GBNFZPFT7UYLMWJ5EMFIBJ6ATW7RUA/appdir && /home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/mvn-3.2.5/bin/mvn -X -D maven.repo.local=/home/jenkins/.m2/repository -s /tmp/release-settings1714400534004224741.xml -D skipTests=true -D build.phase.beforeDeploy=true -P nexus versions:update-parent -N -DallowSnapshots=true '-DparentVersion=[1.8.0' '1.9.0)'
[INFO] [DEBUG] === REACTOR BUILD PLAN ================================================
[INFO] [DEBUG] Project: my-project:pom:6.4.123-SNAPSHOT
[INFO] [DEBUG] Tasks: [versions:update-parent, 1.9.0)]
INFO] [ERROR] Unknown lifecycle phase "1.9.0)". You must specify a valid lifecycle phase...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project grin-colis: Maven execution failed, exit code: '1' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project grin-colis: Maven execution failed, exit code: '1'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
你有没有遇到过类似的问题?你是怎么处理的?
设置
构建运行在 linux Docker 从属设备上(容器不由 Jenkins 管理)。
版本
- 詹金斯 2.46.1
- 管道 2.5
- Maven 集成插件 2.16
- 容器 JDK OpenJDK 1.8.0_121
- Job JDK Oracle JDK 6u45(项目需要 java 6,使用自动安装选项并在 Jenkinsfile 工具部分声明)
- Maven 3.2.5
- Maven 版本插件 2.4(在 pom 中声明)
【问题讨论】:
-
单引号符号用不收,可能是
-DparentVersion='[1.8.0 1.9.0)' -
我不明白的第一件事是,如果您使用 maven-release-plugin,为什么还要使用versions-maven-plugin?为什么要重新定义
preparationGoals和completionGoals?在发布过程中需要更新父级吗? -
@khmarbaise 我不是发布过程本身的作者。我只应该将它移植到 Jenkins 管道,最好尽可能少地改变它。
标签: maven jenkins jenkins-plugins jenkins-pipeline