Hello Maven / Perforce Experts,
I am trying to implement auto versioning of the maven artifacts for a project that uses Perforce as VCS. That made me choose maven-scm-plugin and maven-release-plugin to achieve my purpose. We use triggers in perforce, which checks for violations in the xml content for each commit.
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. However, as you can see the change is submitted to perforce eventually.
STACK TRACE USING XML WHICH HAS TRIGGER ENABLED
[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. I am not sure why maven wont honor the perforce triggers.
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
STACK TRACE USING TXT WHICH DOESNT HAVE TRIGGER
[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:
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
Be careful with this syntax, it's a little persnickety:
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