I'm trying to create a hotfix version from within a Jenkinsfile using the Git-Flow Maven Plugin.
After some initial success, I see now some strange behaviour.
I have the following support branch for stabilization: support/release-3.x
First I run the following Maven command:
mvn -e -B -Dmaven.test.failure.ignore=true -DperformRelease=true gitflow:hotfix-start -DfromBranch=support/release-3.x -DhotfixVersion=3.4.0
This results in the following output:
[INFO] --- gitflow-maven-plugin:1.14.0:hotfix-start (default-cli) @ my-project ---
[INFO] Checking for uncommitted changes.
[INFO] Checking out 'support/release-3.x' branch.
[INFO] Fetching remote branch 'origin support/release-3.x'.
[INFO] Comparing local branch 'support/release-3.x' with remote 'origin/support/release-3.x'.
[INFO] Creating a new branch 'hotfix/support/release-3.x/3.4.0' from 'support/release-3.x' and checking it out.
[INFO] Updating version(s) to '3.4.0'.
[INFO] Committing changes.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------
As you can see, the plugin creates for some reason the branch hotfix/support/release-3.x/3.4.0
instead of hotfix/3.4.0
.
Afterwards the following command gets executed:
mvn -e -B -Dmaven.test.failure.ignore=true -DperformRelease=true gitflow:hotfix-finish -DhotfixVersion=3.4.0 -DpostHotfixGoals=deploy -e -B -Dmaven.test.failure.ignore=true -DperformRelease=true -Dverbose=true
And this results in:
[INFO]
[INFO] --- gitflow-maven-plugin:1.14.0:hotfix-finish (default-cli) @ my-project ---
[INFO] Checking for uncommitted changes.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.721 s
[INFO] Finished at: 2021-01-03T14:06:38+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.14.0:hotfix-finish (default-cli) on project my-project: hotfix-finish: Hotfix branch with name 'hotfix/3.4.0' doesn't exist. Cannot finish hotfix. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.14.0:hotfix-finish (default-cli) on project my-project: hotfix-finish
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: hotfix-finish
at com.amashchenko.maven.plugin.gitflow.GitFlowHotfixFinishMojo.execute (GitFlowHotfixFinishMojo.java:356)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: Hotfix branch with name 'hotfix/3.4.0' doesn't exist. Cannot finish hotfix.
at com.amashchenko.maven.plugin.gitflow.GitFlowHotfixFinishMojo.execute (GitFlowHotfixFinishMojo.java:137)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
So in particular: Hotfix branch with name 'hotfix/3.4.0' doesn't exist. Cannot finish hotfix.
I also checked the Maven Site documentation but couldn't find a parameter which could help.
What am I missing? How can this be solved?
Update 1
Same behaviour with gitflow-maven-plugin v1.15.0
Update 2
I tried now to manually rename the branch between hotfix-start
and hotfix-finish
.
Now I get the following error:
[INFO] --- gitflow-maven-plugin:1.15.0:hotfix-finish (default-cli) @ my-project ---
[INFO] Checking for uncommitted changes.
[INFO] Fetching remote branch 'origin hotfix/3.4.0'.
[WARNING] There were some problems fetching remote branch 'origin hotfix/3.4.0'. You can turn off remote branch fetching by setting the 'fetchRemote' parameter to false.
[INFO] Fetching remote branch 'origin develop'.
[WARNING] There were some problems fetching remote branch 'origin develop'. You can turn off remote branch fetching by setting the 'fetchRemote' parameter to false.
[INFO] Local branch 'master' doesn't exist. Trying to fetch and check it out from 'origin'.
[INFO] Fetching remote branch 'origin master'.
[INFO] Creating a new branch 'master' from 'origin/master' and checking it out.
[INFO] Fetching remote branch 'origin master'.
[INFO] Comparing local branch 'master' with remote 'origin/master'.
[INFO] Checking out 'hotfix/3.4.0' branch.
[INFO] Cleaning and testing the project.
[INFO] Checking out 'master' branch.
[INFO] Merging (--no-ff) 'hotfix/3.4.0' branch.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
So hotfix-finish wants to merge develop
and master
instead of support/release-3.x
I guess I could set fetchRemote
to false
and skipMergeDevBranch
and skipMergeProdBranch
to true
, but how can I merge back to the support branch?
Solution as provider by aleksandr-m at https://github.com/aleksandr-m/gitflow-maven-plugin/issues/273:
In hotfix-finish
use:
-DhotfixVersion=support/release-3.x/3.4.0