Maven + Mercurial:执行命令标记时出错

时间:2011-02-20 17:44:10

标签: mercurial maven maven-release-plugin

我想使用Maven-Release-Plugin发布我的项目的新版本。

但我收到以下错误:

[INFO] Tagging release with the label softsmithy-lib-v0.1...                                                                                     
[INFO] EXECUTING: /bin/sh -c cd /var/lib/hudson/jobs/SoftSmithy-Utility-Library-Release && hg tag --message '[maven-release-plugin]  copy for tag softsmithy-lib-v0.1' softsmithy-lib-v0.1                                                                                                        
[ERROR]                                                                                                                                          
EXECUTION FAILED                                                                                                                                 
  Execution of cmd : tag failed with exit code: 255.                                                                                             
  Working directory was:                                                                                                                         
    /var/lib/hudson/jobs/SoftSmithy-Utility-Library-Release                                                                                      
  Your Hg installation seems to be valid and complete.                                                                                           
    Hg version: 1.7.5 (OK)                                                                                                                       


[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR                                                            
[INFO] ------------------------------------------------------------------------
[INFO] An error is occurred in the tag process: Exception while executing SCM command.

Error while executing command tag --message [maven-release-plugin]  copy for tag softsmithy-lib-v0.1 softsmithy-lib-v0.1
[INFO] ------------------------------------------------------------------------                                         
[INFO] Trace                                                                                                            
org.apache.maven.lifecycle.LifecycleExecutionException: An error is occurred in the tag process: Exception while executing SCM command.
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)                         
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)                
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)                          
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)         
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)                  
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)                              
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)                                                              
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)                                                                
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)                                                                       
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)                                                     
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)                                               
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)                                       
        at java.lang.reflect.Method.invoke(Method.java:597)                                                                            
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)                                                         
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)                                                                 
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)                                                       
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)                                                                   
Caused by: org.apache.maven.plugin.MojoExecutionException: An error is occurred in the tag process: Exception while executing SCM command.
        at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:215)                                
        at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:181)                                       
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)                                        
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)                            
        ... 17 more                                                                                                                       
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: An error is occurred in the tag process: Exception while executing SCM command.                                                                                                                                             
        at org.apache.maven.shared.release.phase.ScmTagPhase.execute(ScmTagPhase.java:113)                                                       
        at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:203)                                         
        at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:140)                                         
        at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:103)                                         
        at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:211)                                       
        ... 20 more                                                                                                                              
Caused by: org.apache.maven.scm.ScmException: Exception while executing SCM command.                                                             
        at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:63)                                                         
        at org.apache.maven.scm.provider.hg.HgScmProvider.tag(HgScmProvider.java:239)                                                            
        at org.apache.maven.scm.provider.AbstractScmProvider.tag(AbstractScmProvider.java:706)                                                   
        at org.apache.maven.shared.release.phase.ScmTagPhase.execute(ScmTagPhase.java:109)                                                       
        ... 24 more                                                                                                                              
Caused by: org.apache.maven.scm.ScmException: Error while executing command tag --message [maven-release-plugin]  copy for tag softsmithy-lib-v0.1 softsmithy-lib-v0.1                                                                                                                            
        at org.apache.maven.scm.provider.hg.command.tag.HgTagCommand.executeTagCommand(HgTagCommand.java:105)                                    
        at org.apache.maven.scm.command.tag.AbstractTagCommand.executeCommand(AbstractTagCommand.java:81)                                        
        at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:59)                                                         
        ... 27 more         

我试图运行

/bin/sh -c cd /var/lib/hudson/jobs/SoftSmithy-Utility-Library-Release && hg tag --message '[maven-release-plugin]  copy for tag softsmithy-lib-v0.1' softsmithy-lib-v0.1

它工作正常!

任何想法出了什么问题?

PS:我注意到以下网站: http://maven.apache.org/scm/matrix.html

提到不支持Mercurial标记命令,但它似乎执行命令(然后以某种方式失败)。如何在Mercurial中使用Maven Release Plugin?

PPS:这似乎只适用于多模块项目。单个POM项目运行良好。我试过-DpreparationGoals =“干净安装”,但没有帮助。

3 个答案:

答案 0 :(得分:6)

我终于找到了解决方案:

所需的父POM

<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>6</version>

使用Maven Release Plugin版本2.0

不幸的是,使用Mercurial的多模块项目存在问题。 使用2.1版时,问题就消失了

解决方法:覆盖项目POM /项目父POM中的版本。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.1</version>
  <configuration>
    <mavenExecutorId>forked-path</mavenExecutorId>
    <useReleaseProfile>false</useReleaseProfile>
    <arguments>-Psonatype-oss-release</arguments>
  </configuration>
</plugin>

我在这里提出了一个问题: https://issues.sonatype.org/browse/OSSRH-1388

答案 1 :(得分:0)

如果您查看HgTagCommand.java的源文件,它会包含一些启动此类异常的地方(例如“Error while executing command”):

关于tag [message]的问题是:

ScmResult result = HgUtils.execute( branchConsumer, getLogger(), workingDir, branchCmd );
HgScmProviderRepository repository = (HgScmProviderRepository) scmProviderRepository;

if ( !result.isSuccess() )
{
  throw new ScmException( "Error while executing command " + joinCmd( branchCmd ) );
}

这看起来与多模块项目不兼容,您可以在其中拥有多个 Mercurial存储库。

答案 2 :(得分:0)

我遇到了同样的问题,因为maven release提交了3次提交(至少在mercurial中):

  • 准备发布
  • 制作发布的标签
  • 准备下一次开发迭代

有时,如果您的项目或发布插件的配置配置不正确,release会陷入第一次提交。问题是,有时它已经将发布更新到你的sonatype服务器,所以你必须从sonatype服务器删除这个假发布,配置你的父项目的pom.xml,编译项目,然后再次发布。 这是我在项目1.0.0-alpha5中删除我的错误发布bridje-parent时的样子:

enter image description here

同时删除位于其子模块中的假release。在制作scm之前,请务必在release服务器中提交更改。 投票,如果它对你有用,它很少发生在我身上。