简体   繁体   English

Maven SCM不监听perforce触发输出

[英]maven scm does not listen to perforce trigger output

Hello Maven / Perforce Experts, 您好Maven / Perforce专家,

I am trying to implement auto versioning of the maven artifacts for a project that uses Perforce as VCS. 我正在尝试为使用Perforce作为VCS的项目实现Maven工件的自动版本控制。 That made me choose maven-scm-plugin and maven-release-plugin to achieve my purpose. 那使我选择了maven-scm-plugin和maven-release-plugin来达到我的目的。 We use triggers in perforce, which checks for violations in the xml content for each commit. 我们在perforce中使用触发器,该触发器检查每个提交的xml内容中是否存在违例。

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

Unfortunately, when I run the command “mvn -X -e -B scm:edit release:update-versions scm:checkin“ to edit the file, update the version and submit to perforce, maven does NOT honor the result from the perforce trigger and fails the build. 不幸的是,当我运行命令“ mvn -X -e -B scm:edit release:update-versions scm:checkin”以编辑文件,更新版本并提交给perforce时,maven不遵守perforce触发器的结果并导致构建失败。 However, as you can see the change is submitted to perforce eventually. 但是,您可以看到更改最终将提交给perforce。

STACK TRACE USING XML WHICH HAS TRIGGER ENABLED 使用已启用触发器的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

I submitted the file locally to ensure perforce trigger doesn't spit a failure status code and it actually returns SUCCESS too. 我在本地提交了文件,以确保perforce触发器不会吐出故障状态代码,并且它实际上也返回SUCCESS。 I am not sure why maven wont honor the perforce triggers. 我不确定为什么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

I tested a scenario with a txt file which doesn't have perforce trigger enabled and maven returns build result as SUCCESS, because technically it doesn't go through a perforce trigger 我用未启用perforce触发器的txt文件测试了一个方案,并且maven将构建结果返回为SUCCESS,因为从技术上讲,它不会通过perforce触发器

STACK TRACE USING TXT WHICH DOESNT HAVE TRIGGER 使用没有触发的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] ------------------------------------------------------------------------

QUESTION: 题:

  1. Has anyone experienced this behavior with maven and how did you workaround? 有没有人遇到过Maven的这种行为,您如何解决?
  2. Would you know if it is possible to disable perforce trigger for a particular file, so that perforce doesn't even go through the trigger 您是否可以为特定文件禁用perforce触发器,以使perforce甚至不会通过触发器

You can use exclusionary syntax (a leading hyphen in the path field) in your triggers table to specify that certain files or patterns are not to run the trigger. 您可以在触发器表中使用排他性语法(路径字段中的前导连字符)来指定某些文件或模式不运行触发器。

There is an example of this in the 'p4 triggers' documentation: http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_triggers.html “ p4触发器”文档中有一个示例: http : //www.perforce.com/perforce/doc.current/manuals/cmdref/p4_triggers.html

Be careful with this syntax, it's a little persnickety: 使用这种语法要小心,这有点让人讨厌:

  1. The triggers are grouped based on trigger name and type 触发器根据触发器名称和类型分组
  2. The order of the lines in the trigger table for a group matters 触发器表中各组的行顺序很重要

There is also a knowledge base article for this feature that goes into some more detail: http://answers.perforce.com/articles/KB_Article/Excluded-Trigger-Paths-Not-Being-Recognized 此功能的知识库文章也有更详细的说明: http : //answers.perforce.com/articles/KB_Article/Excluded-Trigger-Paths-Not-Being-Recognized

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM