【问题标题】:Maven Release Plugin aborts prepare because of local modifications in jenkins由于 jenkins 中的本地修改,Maven 发布插件中止准备
【发布时间】:2017-01-17 08:48:07
【问题描述】:

问题:

当我执行 maven 发布插件的准备目标时,我得到了错误

[错误] 无法在项目 my-artifact-id 上执行目标 org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli):无法准备发布,因为您有本地修改:

[错误] [我的项目名称\src\main\java\some\packages\SomeJavaSourceFile.java:modified]

...

[错误] [我的项目名称\src\main\java\some\packages\SomeOtherJavaSourceFile.java:modified]

大约 20 个文件。

详情

  • 发布插件由 Jenkins 执行。
  • SVN 配置为“始终签出新副本”
  • Maven 发布插件用于目标-Dresume=false clean release:prepare release:perform
  • 修改后的文件在上次提交中被修改过。
  • 执行准备目标期间发生错误:

    [INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) @ artifact-id

  • 发布插件在过去 11 次中成功运行(但有时第一次尝试不起作用,但第二次运行)

类似问题

为什么其他问题没有帮助:

日志

我试着匿名了,所以你发现有些部分被[替换部分的含义]替换了

Started by user Sergej Werfel
[EnvInject] - Loading node environment variables.
Building remotely on Build in workspace E:\Jenkins\Build\workspace\project-dir
Cleaning local Directory .
Checking out [svn-url] at revision '2016-09-09T10:12:55.444 +0200'
...
A         some file
...
AU        some other file
AU        pom.xml
AU        event more files
...
 U        .
At revision 1639745
no change for [svn-url] since the previous build
Injecting SonarQube environment variables using the configuration: Sonar 5
Parsing POMs
Injecting SonarQube environment variables using the configuration: Sonar 5
using global settings config with name MVN Settings [setting name]
Replacing all maven server entries not found in credentials list is true
Injecting SonarQube environment variables using the configuration: Sonar 5
Injecting SonarQube environment variables using the configuration: Sonar 5
Injecting SonarQube environment variables using the configuration: Sonar 5
Injecting SonarQube environment variables using the configuration: Sonar 5
Injecting SonarQube environment variables using the configuration: Sonar 5
Injecting SonarQube environment variables using the configuration: Sonar 5
Injecting SonarQube environment variables using the configuration: Sonar 5
Established TCP socket on 18423
maven32-agent.jar already up to date
maven32-interceptor.jar already up to date
maven3-interceptor-commons.jar already up to date
[project name] $ "C:\Program Files\Java\jdk1.8.0_51/bin/java" -cp E:\Jenkins\Build\maven32-agent.jar;C:\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;C:\apache-maven-3.3.9/conf/logging jenkins.maven3.agent.Maven32Main C:\apache-maven-3.3.9 E:\Jenkins\Build\slave.jar E:\Jenkins\Build\maven32-interceptor.jar E:\Jenkins\Build\maven3-interceptor-commons.jar 18423
<===[JENKINS REMOTING CAPACITY]===>channel started
using global settings config with name MVN Settings [setting name]
Replacing all maven server entries not found in credentials list is true
Executing Maven:  -B -f [path to root pom]\pom.xml -gs [path to settings]\global-settings1467677761792043752.xml -DdevelopmentVersion=0.1.13-SNAPSHOT -DreleaseVersion=0.1.12 -Dresume=false -DdryRun=true clean release:prepare
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] [project name]
[INFO] module-1
[INFO] module-2
[INFO] module-3
[INFO] module-4
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building root project name 0.1.12-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ root-project ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building module-1 0.1.12-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module-1 ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building module-2 0.1.12-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module-2 ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building module-3 0.1.12-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module-3 ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building module-4 0.1.12-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ module-4 ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building project name 0.1.12-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) @ root-project ---
[INFO] Verifying that there are no local modifications...
[INFO]   ignoring changes on: **\pom.xml.next, **\release.properties, **\pom.xml.branch, **\pom.xml.tag, **\pom.xml.backup, **\pom.xml.releaseBackup
[INFO] Executing: cmd.exe /X /C "svn --non-interactive status"
[INFO] Working directory: E:\Jenkins\Build\workspace\project-dir
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] root-project ................................ FAILURE [  1.016 s]
[INFO] module-1 .......................... SUCCESS [  0.047 s]
[INFO] module-2 ............................ SUCCESS [  0.049 s]
[INFO] module-3 ....................... SUCCESS [  0.084 s]
[INFO] module-4 ........................ SUCCESS [  0.068 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.089 s
[INFO] Finished at: 2016-09-09T10:13:08+02:00
[INFO] Final Memory: 15M/234M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project root-project: Cannot prepare the release because you have local modifications :
[ERROR] [module-1\src\test\java\package\SomeJavaTest.java:modified]
[ERROR] [... some other files ...]
[ERROR] [module-2\src\main\java\package\SomeJavaFile.java:modified]
[ERROR] [... some other files ...]
[ERROR] [module-2\src\test\java\package\AnOtherTestTest.java:modified]
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[JENKINS] Archiving E:\Jenkins\Build\workspace\project-dir\module-1\pom.xml to [some path]/0.1.12-SNAPSHOT/module-1-0.1.12-SNAPSHOT.pom
[other modules]
[M2Release] its only a dryRun, no need to mark it for keep
channel stopped
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: FAILURE

项目结构

- root-dir
|- module-1-dir
|'- module-1-pom
|- module-2-dir
|'- module-1-pom
| ...
'-root-pom

【问题讨论】:

  • 首先你为什么要使用这么旧版本的maven-release-plugin?发布步骤之前是否有修改文件的步骤?如果没有完整的日志输出,很难看出哪里出了问题..
  • 我将整个日志(匿名)添加到问题中。我使用 maven 3.3.9 和默认定义的发布插件版本
  • 强制使用 org.apache.maven.plugins:maven-release-plugin:2.5.3 并不能解决问题(同样的错误)
  • 根 pom 在哪里?你的项目结构如何(文件夹结构)?
  • 添加项目结构到问题:根 pom 在根目录中

标签: java maven svn jenkins maven-release-plugin


【解决方案1】:

按照以下步骤解决

  1. scm 标签(连接、开发者连接和 url)和发布插件从父 pom 移动到子 pom。
  2. 在 maven 命令中使用了 -B 选项 示例:mvn -B -f pom.xml -DdevelopmentVersion=&lt;developmentVersion&gt; -DreleaseVersion=&lt;releaseVersion&gt; -Dusername=&lt;scmUserName&gt; -Dtag=&lt;releaseVersion&gt; -Dresume=false release:prepare release:perform versions:use-latest-releases -Dpassword=&lt;scmPassword&gt;

【讨论】:

  • 感谢您的回答。不幸的是,我不再参与该项目,在那里我遇到了这个问题。所以我无法验证它。我希望它会帮助其他人。
【解决方案2】:

概述

提交的文件只有\n( = lf = line feed) 作为以颠覆结尾的行。它们是在 Windows 机器上签出的,所以结尾变成了\r\n(= crlf = carriage return and line feed)。因此,文件已更改为“已修改”。直接使用\r\n-ending 修复该签入文件。

查找方式

  • 在 Jenkins 上重新签出后,您可以运行“svn status”作为脚本来查看文件被标记为“已修改”的确切程度。
  • 当您调用“svn diff”时,您会看到,每个文件的每一行都不同,但您看不到差异 => 不可见的变化
  • 从 jenkins 工作区打开一个修改过的文件,从 svn repo 打开一个修改后的文件,然后使用可以可视化不可见字符的编辑器查看它们(例如,使用工具栏中“显示所有字符”的 Notepad++)

原因

发生这种情况的原因是 git-svn 的错误使用。我使用 git-svn 检查了这些文件,而没有更改“autocrlf”设置。 Git 在提交到本地 repo 时将结尾更改为 \n。推送到 svn 时,行尾仍然是 \n

修复

  • 使用 svn 客户端结帐,更改行尾,提交。
  • 或在 git 中将“autocrlf”设置为false。使用 git-svn 检查,更改行尾,dcommit。

以后如何避免

Git 有一个设置“autocrlf”。关闭它似乎可以解决问题

【讨论】:

    猜你喜欢
    • 2013-04-18
    • 1970-01-01
    • 2014-09-12
    • 2012-02-26
    • 1970-01-01
    • 1970-01-01
    • 2013-04-02
    • 2016-09-09
    • 2015-07-09
    相关资源
    最近更新 更多