1

您好 Maven / Perforce 专家,

我正在尝试为使用 Perforce 作为 VCS 的项目实现 Maven 工件的自动版本控制。这让我选择了 maven-scm-plugin 和 maven-release-plugin 来实现我的目的。我们在 perforce 中使用触发器,它检查每个提交的 xml 内容中的违规行为。

    checkstyle_xml change-content //depot/project/....xml " /p4/triggers/checkstyle-trigger.pl %user% %changelist% /p4"

不幸的是,当我运行命令“mvn -X -e -B scm:edit release:update-versions scm:checkin”来编辑文件、更新版本并提交到 perforce 时,maven 不尊重 perforce 触发器的结果并且构建失败。但是,正如您所见,更改最终会提交给 perforce。

使用已启用触发器的 XML 的堆栈跟踪

[DEBUG] Sending changelist:
Change: new

Description:
    Auto increment pom version during build process. Reviewed by: RE

Files:
    //depot/project/pom.xml

[ERROR] Provider message:
[ERROR] Unable to submit
[ERROR] Command output:
[ERROR] Debug: starting trigger script  
Change 351157 submitted.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.112s
[INFO] Finished at: Thu Oct 30 14:51:51 PDT 2014
[INFO] Final Memory: 23M/219M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.7:checkin (default-cli) on project phoenix: Command failed.Unable to submit -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal     org.apache.maven.plugins:maven-scm-plugin:1.7:checkin (default-cli) on project phoenix: Command failed.Unable to submit
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Command failed.Unable to submit
    at org.apache.maven.scm.plugin.AbstractScmMojo.checkResult(AbstractScmMojo.java:439)
    at org.apache.maven.scm.plugin.CheckinMojo.execute(CheckinMojo.java:83)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
[ERROR] 
[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/MojoExecutionException

我在本地提交了文件以确保 perforce 触发器不会吐出失败状态代码,并且它实际上也返回了 SUCCESS。我不确定为什么 maven 不会尊重 perforce 触发器。

p4 –u testuser submit -d "Test" pom.xml 
Submitting change 351166.
Locking 1 files ...
edit //depot/project/pom.xml#25
Debug: starting trigger script  
Change 351166 submitted.

$ echo $?
0

我使用未启用 perforce 触发器的 txt 文件测试了一个场景,并且 maven 将构建结果返回为 SUCCESS,因为从技术上讲,它不会通过 perforce 触发器

使用没有触发的 TXT 进行堆栈跟踪

[DEBUG] Sending changelist:
Change: new

Description:
    Auto increment pom version during build process. Reviewed by: RE

Files:
    //depot/phoenix/auto-increment-pom/pom.txt

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.998s
[INFO] Finished at: Thu Oct 30 14:55:04 PDT 2014
[INFO] Final Memory: 18M/216M
[INFO] ------------------------------------------------------------------------

问题:

  1. 有没有人经历过 maven 的这种行为,你是如何解决的?
  2. 你知道是否可以为特定文件禁用 perforce 触发器,这样 perforce 甚至不会通过触发器
4

1 回答 1

1

您可以在触发器表中使用排除语法(路径字段中的前导连字符)来指定某些文件或模式不运行触发器。

在“p4 触发器”文档中有一个示例:http ://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_triggers.html

小心这种语法,它有点小气:

  1. 触发器根据触发器名称和类型进行分组
  2. 组的触发器表中的行顺序很重要

还有一篇关于此功能的知识库文章更详细地介绍了:http: //answers.perforce.com/articles/KB_Article/Excluded-Trigger-Paths-Not-Being-Recognized

于 2014-11-04T14:40:41.893 回答