@@ -175,6 +175,15 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
175
175
@ Parameter (property = "updateOutputTimestamp" , defaultValue = "true" )
176
176
private boolean updateOutputTimestamp = true ;
177
177
178
+ /**
179
+ * Options to pass to Git push command using <code>--push-option</code>.
180
+ * Multiple options can be added separated with a space e.g.
181
+ * <code>-DgitPushOptions="merge_request.create merge_request.target=develop
182
+ * merge_request.label='Super feature'"</code>
183
+ */
184
+ @ Parameter (property = "gitPushOptions" )
185
+ private String gitPushOptions ;
186
+
178
187
/**
179
188
* The path to the Maven executable. Defaults to "mvn".
180
189
*/
@@ -1042,19 +1051,33 @@ private boolean gitFetchRemote(final String branchName)
1042
1051
* @throws CommandLineException
1043
1052
* If command line execution fails.
1044
1053
*/
1045
- protected void gitPush (final String branchName , boolean pushTags )
1046
- throws MojoFailureException , CommandLineException {
1047
- getLog ().info (
1048
- "Pushing '" + branchName + "' branch" + " to '"
1049
- + gitFlowConfig .getOrigin () + "'." );
1054
+ protected void gitPush (final String branchName , boolean pushTags ) throws MojoFailureException , CommandLineException {
1055
+ getLog ().info ("Pushing '" + branchName + "' branch to '" + gitFlowConfig .getOrigin () + "'." );
1056
+
1057
+ List <String > args = new ArrayList <>();
1058
+ args .add ("push" );
1059
+ args .add ("--quiet" );
1060
+ args .add ("-u" );
1050
1061
1051
1062
if (pushTags ) {
1052
- executeGitCommand ("push" , "--quiet" , "-u" , "--follow-tags" ,
1053
- gitFlowConfig .getOrigin (), branchName );
1054
- } else {
1055
- executeGitCommand ("push" , "--quiet" , "-u" ,
1056
- gitFlowConfig .getOrigin (), branchName );
1063
+ args .add ("--follow-tags" );
1057
1064
}
1065
+
1066
+ if (StringUtils .isNotBlank (gitPushOptions )) {
1067
+ try {
1068
+ String [] opts = CommandLineUtils .translateCommandline (gitPushOptions );
1069
+ for (String opt : opts ) {
1070
+ args .add ("--push-option=" + opt );
1071
+ }
1072
+ } catch (Exception e ) {
1073
+ throw new CommandLineException (e .getMessage (), e );
1074
+ }
1075
+ }
1076
+
1077
+ args .add (gitFlowConfig .getOrigin ());
1078
+ args .add (branchName );
1079
+
1080
+ executeGitCommand (args .toArray (new String [0 ]));
1058
1081
}
1059
1082
1060
1083
protected void gitPushDelete (final String branchName )
0 commit comments