由于jenkins的局部修改,Maven Release Plugin中止准备

时间:2016-09-09 08:51:26

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

问题:

当我执行maven release插件的准备目标时,我收到错误

  

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

     

[错误] [my-project-name \ src \ main \ java \ some \ packages \ SomeJavaSourceFile.java:modified]

     

...

     

[错误] [my-project-name \ 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

2 个答案:

答案 0 :(得分:2)

<强>概述

提交的文件只有\n(= lf = line feed)作为以subversion结尾的行。他们在Windows机器上签出,结果变为\r\n(= crlf = carriage return and line feed)。因此,文件已被更改为“已修改”。使用\r\n修复对该文件的检查 - 直接结束。

查找方式

  • 在Jenkins结帐后,您可以运行“svn status”作为skript来查看,这些文件被标记为“已修改。”
  • 当您调用“svn diff”时,您会看到每行中的每个文件都不同,但您看不到差异=&gt;不可见的变化
  • 从jenkins工作区打开一个这样的修改过的文件,从svn repo打开一个这样的修改过的文件,用一个可以显示非可见字符的编辑器查看它们(例如Notepad ++,工具栏中显示“show all characters”)

<强>原因

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

<强>修正

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

将来如何避免

Git有一个设置“autocrlf”。转向它似乎解决了问题

答案 1 :(得分:0)

执行以下步骤后解决了

  1. scm tag(connection,developerconnection和url)和release插件从父pom移动到child pom。
  2. maven命令中使用了-B选项 示例:mvn -B -f pom.xml -DdevelopmentVersion=<developmentVersion> -DreleaseVersion=<releaseVersion> -Dusername=<scmUserName> -Dtag=<releaseVersion> -Dresume=false release:prepare release:perform versions:use-latest-releases -Dpassword=<scmPassword>