您好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
我测试了一个带有txt文件的场景,该文件没有启用perforce触发器,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] ------------------------------------------------------------------------
问题:
答案 0 :(得分:1)
您可以在触发器表中使用排除语法(路径字段中的前导连字符)来指定某些文件或模式不会运行触发器。
“p4触发器”文档中有一个示例:http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_triggers.html
小心这种语法,这有点不耐烦:
此功能的知识库文章更详细地介绍了一些:http://answers.perforce.com/articles/KB_Article/Excluded-Trigger-Paths-Not-Being-Recognized