aleksandr-m / gitflow-maven-plugin

The Git-Flow Maven Plugin supports various Git workflows, including GitFlow and GitHub Flow. This plugin runs Git and Maven commands from the command line.
https://aleksandr-m.github.io/gitflow-maven-plugin/
Apache License 2.0
490 stars 182 forks source link

Feature finish cannot finish current branch in batch mode #270

Closed CallumKerson closed 3 years ago

CallumKerson commented 3 years ago

When in interactive mode, doing a gitflow:feature-finish in a feature branch will give the current branch as the default option. When in batch (non-interactive) mode, there is no option to finish the current branch, if the current branch is a feature branch.

This would be useful when finishing as part of CI that autodetect feature branches and checks them out, then all the current maven commands are made against the checked-out branch.

aleksandr-m commented 3 years ago

You can use featureName parameter.

CallumKerson commented 3 years ago

But there are environments where you won’t easily be able to determine what the current branch name is, like on some CI tasks, and even when you can evaluate the current branch name the featureName parameter does not support a value that starts with the prefix. If you evaluate the current branch then use the featureName parameter you end up with an error saying it cannot finish feature/feature/a-branch.

CallumKerson commented 3 years ago

@aleksandr-m should the compromise be to allow the featureName parameter to detect the existence of the feature prefix at the start of the parameter so it should not double up on the feature prefix.

For example, if you use gitflow:feature-finish -DfeatureName=feature/my-new-component, this would succeed instead of failing with the message "Cannot find feature branch feature/feature/my-new-component"

aleksandr-m commented 3 years ago

Ahh, I see now. I'll think about that.

aleksandr-m commented 3 years ago

@CallumKerrEdwards I've added featureBranch and hotfixBranch parameters to respective finish goals which allow to use full branch names in non-interactive mode.

CallumKerson commented 3 years ago

@aleksandr-m Fantastic, thanks. Do you have an ETA for the next release? Thanks again

aleksandr-m commented 3 years ago

@CallumKerrEdwards Sorry, I don't have ETA. It depends on the feature implemented, bugs found, and my free time :).

aleksandr-m commented 3 years ago

@CallumKerrEdwards 1.16.0 is released.

CallumKerson commented 3 years ago

Thanks very much :)

shvalb commented 3 years ago

I tried to call "gitflow:feature-finish from bitbucket_pipelines.yml on 'develop' branch as follow:

mvn -B gitflow:feature-finish -DincrementVersionAtFinish -DfeatureBranch="feature/Attempt-9"

even hardcoded the feature branch name just to be on the safe side...

and the error was:

[ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.16.0:feature-finish (default-cli) on project game-servers: feature-finish: Feature branch with name 'feature/Attempt-9' doesn't exist. Cannot finish feature. -> [Help 1]

Here is a snippet from my bitbucket_pipelines.yml file:

FROM ...
...
    develop:
      - step:
          name: Build & Verify after merge to 'develop' Branch
          caches:
            - maven
          script:
            - mvn clean verify 
      - step:
          name: Build to QA/Staging
          trigger: manual
          caches:
            - maven
          script:
            - mvn -B gitflow:feature-finish -DincrementVersionAtFinish -DfeatureBranch="feature/Attempt-9"
            - mvn -s settings.xml clean deploy
...

Any idea what am I doing wrong?

The only thing I can think of, is that I first clicked on the "Merge" button on Bitbucket (but I left the feature-branch opened")...so perhaps the plugin fails because of this...

Thanks.