You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -143,8 +144,8 @@ One common stumbling block for teams adjusting to gitflow with Maven projects is
143
144
In practice, the Maven versions should:
144
145
145
146
* Be synchronized with release branch and hotfix branch names.
146
-
* Never be -SNAPSHOT in the master, support, release, or hotfix branches.
147
-
* Always be -SNAPSHOT in the develop branch.
147
+
* Never be -SNAPSHOT in the master, support, release, or hotfix branches. Also, no -SNAPSHOT parent or (plugin) dependencies are allowed. (This condition may be disabled by setting `enforceNonSnapshots` = `false`.)
148
+
* Always be -SNAPSHOT in the feature and develop branches.
148
149
* Be irrelevant if there's no git branch resolvable from your environment.
149
150
150
151
The `enforce-versions` goal asserts these semantics when it can resolve the `gitBranchExpression`.
@@ -158,12 +159,17 @@ The following properties change the behavior of this goal:
| gitBranchExpression | current git branch resolved from SCM or ${env.GIT_BRANCH} | n/a | Maven property expression to resolve in order to determine the current git branch |
162
+
| deploySnapshotTypeBranches |`false`| n/a | When `true`, the POM version should end with the feature branch name and -SNAPSHOT, e.g. `1.0.0-myfeature-SNAPSHOT`. This prevents a feature branch snapshot from "overwriting" a snapshot from the develop branch. |
163
+
| enforceNonSnapshots |`true`| n/a | When `true`, enforce the requirement that none of the following may contain a -SNAPSHOT: the POM version, any parent, or any (plugin) dependencies. |
164
+
| releaseBranchMatchType |`equals`| n/a | When `equals`, the POM version should be identical to the branch name for release and hotfix branches (e.g. POM version should be `1.0.0` for branch `release/1.0.0`). When `startsWith`, POM version should start with the name branch (e.g. POM version could be `1.0.1` for branch `release/1.0`. When using the `update-stage-dependencies` mojo, set to `equals`, otherwise set to `startsWith`. |
161
165
| masterBranchPattern | (origin/)?master | No | Regex. When matched, signals the master branch is being built. |
162
166
| supportBranchPattern | (origin/)?support/(.*) | No | Regex. When matches, signals a support branch (long term master-equivalent for older release) being built. Last subgroup, if present, must be start of the Maven project version. |
163
167
| releaseBranchPattern | (origin/)?release/(.*) | No | Regex. When matched, signals a release branch being built. Last subgroup, if present, must match the Maven project version. |
164
168
| hotfixBranchPattern | (origin/)?hotfix/(.*) | No | Regex. When matched, signals a hotfix branch is being built. Last subgroup, if present, must match the Maven project version. |
169
+
| featureOrBugfixBranchPattern | (origin/)?(?:feature|bugfix)/(.*) | Yes | Regex. When matched, signals a feature or bugfix branch is being built. |
165
170
| developmentBranchPattern | (origin/)?develop | Yes | Regex. When matched, signals a development branch is being built. Note the lack of a subgroup. |
166
171
172
+
167
173
## Goal: `retarget-deploy` (Branch Specific Deploy Targets & Staging)
168
174
169
175
One of the challenges of building a good CI/CD job for Maven environments is the lack of a 'staging' repository baked into Maven.
@@ -179,10 +185,12 @@ plugins in the build process (deploy, site-deploy, etc.) will use the repositori
179
185
| Property | Default Value | Description |
180
186
| -------- | ------------- | ----------- |
181
187
| gitBranchExpression | current git branch resolved from SCM or ${env.GIT_BRANCH} | Maven property expression to resolve in order to determine the current git branch |
188
+
| deploySnapshotTypeBranches |`false`| When `true`, feature branches will also be deployed to the snapshots repository. |
182
189
| releaseDeploymentRepository | n/a | The repository to use for releases. (Builds with a GIT_BRANCH matching `masterBranchPattern` or `supportBranchPattern`) |
183
190
| stageDeploymentRepository | n/a | The repository to use for staging. (Builds with a GIT_BRANCH matching `releaseBranchPattern` or `hotfixBranchPattern`) |
184
191
| snapshotDeploymentRepository | n/a | The repository to use for snapshots. (Builds matching `developmentBranchPattern`) |
185
192
193
+
186
194
**The repository properties should follow the following format**, `id::layout::url::uniqueVersion`.
187
195
188
196
When using this plugin, the `<distributionManagement>` repository definitions can be completely removed from your pom.xml
@@ -250,11 +258,11 @@ properties from files with an assigned keyPrefix, letting you name-space propert
250
258
The maven `-U` command line switch does a fine job of updating SNAPSHOT versions from snapshot repositories, there is no
251
259
built-in way to force maven to re-resolve non-snapshot release versions. This goal addresses that shortcoming in a fairly
252
260
straight-forward manner. Any release version dependency of the project which was provided to the local repository by a
253
-
remote repository with the same ID as the `<stageDeploymentRepository>`, will be purged from the local repository and
261
+
remote repository with the same ID as the `<stageDeploymentRepository>`, will be purged from the local repository and
254
262
re-resolved (so you get the latest version from either the stage repository, or your release repository).
255
263
256
-
It is **very important** if you're using this goal, that the **`stageDeploymentReposity` have a unique repository/server id**.
257
-
If you use the same ID for release, snapshot, and stage, every time you exeucte this goal, every release version
264
+
It is **very important** if you're using this goal, that the **`stageDeploymentReposity` have a unique repository/server id**.
265
+
If you use the same ID for release, snapshot, and stage, every time you exeucte this goal, every release version
258
266
dependency will be purged and re-resolved.
259
267
260
268
If you have a local build / install of a release version, this goal will currently not update that package, by design.
@@ -299,7 +307,7 @@ To accomplish this the `promote-master` goal and a Maven build extension work to
299
307
300
308
With the build extension added to your project, any build where the `gitBranchExpression` matches the `masterBranchPattern` or `supportBranchPattern` will have it's
301
309
build lifecycle (plugins, goals, etc) altered. Any plugin other than the gitflow-helper-maven-plugin, the maven-deploy-plugin, or plugins with goals
302
-
explicitly referenced on the command line will be ignored (removed from the project reactor).
310
+
explicitly referenced on the command line will be ignored (removed from the project reactor).
303
311
This allows us to enforce the ideal that code should never be built in the master branch.
304
312
305
313
The `promote-master` goal executes when the `gitBranchExpression` resolves to a value matching the `masterBranchPattern` or `supportBranchPattern` regular expression.
@@ -331,6 +339,7 @@ The following table describes the git branch expression -> repository used for r
331
339
| supportBranchPattern | release |
332
340
| releaseBranchPattern | stage |
333
341
| hotfixBranchPattern | stage |
342
+
| featureOrBugfixBranchPattern | snapshots |
334
343
| developmentBranchPattern | snapshots |
335
344
| All Others | local |
336
345
@@ -352,3 +361,15 @@ it's building. The attach-deploy will 'clean' the maven project, then download t
352
361
that the first build deployed into. Once they're attached to the project, the `jboss-as:deploy-only` goal will deliver
353
362
the artifacts built by the first job into a jboss application server.
354
363
364
+
365
+
# Resolving the Git branch name
366
+
As stated before, the plugin determines what to do by resolving the Git branch name.
367
+
368
+
* The first try is a `git symbolic-ref HEAD` to check the local branch name. If it's found, that's the branch name that's used.
369
+
* If the `symbolic-ref` fails then it's probably due to a detached HEAD. This typically happens on Jenkins, when it simply checks out the commit hash that was just pushed.
370
+
Or, it's because of a developer doing a `git checkout origin/feature/x`, e.g. when doing a code review and no local branch is required.
371
+
In such a case:
372
+
* The plugin will first resolve the HEAD to a commit using `git rev-parse HEAD`.
373
+
* Next, it will do a `git show-ref` to check which (local/remote) branches point to the commit.
374
+
* If it can resolve the commit to a single branch type (e.g. develop or master) then that's the branch name that's used.
375
+
* If all of the above fails, `${env.GIT_BRANCH}` is tried.
0 commit comments