Git-Flow Maven 插件:hotfix 分支
Git-Flow Maven Plugin: hotfix branch
我正在尝试使用 Git-Flow Maven Plugin.
从 Jenkinsfile 中创建修补程序版本
在取得初步成功后,我现在看到了一些奇怪的行为。
我有以下 支持 稳定分支:support/release-3.x
首先我运行下面的Maven命令:
mvn -e -B -Dmaven.test.failure.ignore=true -DperformRelease=true gitflow:hotfix-start -DfromBranch=support/release-3.x -DhotfixVersion=3.4.0
这导致以下输出:
[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] --------------------
如您所见,插件出于某种原因创建了分支 hotfix/support/release-3.x/3.4.0
而不是 hotfix/3.4.0
.
之后执行以下命令:
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
这导致:
[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)
特别是:Hotfix branch with name 'hotfix/3.4.0' doesn't exist. Cannot finish hotfix.
我也检查了 Maven Site documentation 但找不到有用的参数。
我错过了什么?如何解决?
更新 1
与 gitflow-maven-plugin v1.15.0 相同的行为
更新 2
我现在尝试手动重命名 hotfix-start
和 hotfix-finish
之间的分支。
现在我得到以下错误:
[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] ------------------------------------------------------------------------
所以 hotfix-finish 想要合并 develop
和 master
而不是 support/release-3.x
我想我可以将 fetchRemote
设置为 false
并且将 skipMergeDevBranch
和 skipMergeProdBranch
设置为 true
,但是我如何合并回支持分支?
aleksandr-m 在 https://github.com/aleksandr-m/gitflow-maven-plugin/issues/273:
提供的解决方案
在hotfix-finish
中使用:
-DhotfixVersion=support/release-3.x/3.4.0
我正在尝试使用 Git-Flow Maven Plugin.
从 Jenkinsfile 中创建修补程序版本在取得初步成功后,我现在看到了一些奇怪的行为。
我有以下 支持 稳定分支:support/release-3.x
首先我运行下面的Maven命令:
mvn -e -B -Dmaven.test.failure.ignore=true -DperformRelease=true gitflow:hotfix-start -DfromBranch=support/release-3.x -DhotfixVersion=3.4.0
这导致以下输出:
[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] --------------------
如您所见,插件出于某种原因创建了分支 hotfix/support/release-3.x/3.4.0
而不是 hotfix/3.4.0
.
之后执行以下命令:
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
这导致:
[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)
特别是:Hotfix branch with name 'hotfix/3.4.0' doesn't exist. Cannot finish hotfix.
我也检查了 Maven Site documentation 但找不到有用的参数。
我错过了什么?如何解决?
更新 1
与 gitflow-maven-plugin v1.15.0 相同的行为
更新 2
我现在尝试手动重命名 hotfix-start
和 hotfix-finish
之间的分支。
现在我得到以下错误:
[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] ------------------------------------------------------------------------
所以 hotfix-finish 想要合并 develop
和 master
而不是 support/release-3.x
我想我可以将 fetchRemote
设置为 false
并且将 skipMergeDevBranch
和 skipMergeProdBranch
设置为 true
,但是我如何合并回支持分支?
aleksandr-m 在 https://github.com/aleksandr-m/gitflow-maven-plugin/issues/273:
提供的解决方案在hotfix-finish
中使用:
-DhotfixVersion=support/release-3.x/3.4.0