GitVersion
GitVersion copied to clipboard
Azure Pipelines - Pull Request Inheritance
I'm using a trunk-based branching strategy that I'm trying to version using the GitVersion@4 task in Azure Devops. All works perfectly fine when building off feature branches, but Pull Request builds don't appear to be inheriting properly. The flow we have is: feature/bug -> PR -> master -> release
In the log I can see it's using the feature/bug branch itself a base - should it not be the pull request branch?
branches:
feature:
mode: ContinuousDelivery
regex: feature[/-]
increment: Minor
tag: useBranchName
source-branches:
- develop
bug:
mode: ContinuousDelivery
regex: bug[/-]
increment: Patch
tag: useBranchName
source-branches:
- develop
develop:
mode: ContinuousDeployment
regex: master
is-source-branch-for:
- feature
- bug
master:
regex: none
release:
regex: release[/-]
tag: 'rc'
increment: Patch
source-branches:
- develop
2019-02-12T06:55:20.1541113Z INFO [02/12/19 6:55:20:15] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2019-02-12T06:55:20.1618952Z INFO [02/12/19 6:55:20:16] Creating local branch refs/heads/pull/47/merge pointing at 8c67860532d18571431936267369df202c5ca5cd
2019-02-12T06:55:20.2369132Z INFO [02/12/19 6:55:20:23] Skipping update of 'refs/remotes/origin/bug/MAA-132' as it already matches the remote ref.
2019-02-12T06:55:20.2394975Z INFO [02/12/19 6:55:20:23] Skipping update of 'refs/remotes/origin/features/PullRequestTest' as it already matches the remote ref.
2019-02-12T06:55:20.2424231Z INFO [02/12/19 6:55:20:24] Skipping update of 'refs/remotes/origin/master' as it already matches the remote ref.
2019-02-12T06:55:20.2455320Z INFO [02/12/19 6:55:20:24] Skipping update of 'refs/remotes/origin/releases/2.6.0' as it already matches the remote ref.
2019-02-12T06:55:20.2471394Z INFO [02/12/19 6:55:20:24] HEAD points at branch 'refs/heads/pull/47/merge'.
2019-02-12T06:55:20.2488407Z INFO [02/12/19 6:55:20:24] End: Normalizing git directory for branch 'refs/pull/47/merge' (Took: 622.39ms)
2019-02-12T06:55:20.2489447Z INFO [02/12/19 6:55:20:24] IsDynamicGitRepository: False
2019-02-12T06:55:20.2490902Z INFO [02/12/19 6:55:20:24] Returning Project Root from DotGitDirectory: /workspace/3/s/.git - /workspace/3/s
2019-02-12T06:55:20.2491523Z INFO [02/12/19 6:55:20:24] Project root is: /workspace/3/s
2019-02-12T06:55:20.2491664Z INFO [02/12/19 6:55:20:24] DotGit directory is: /workspace/3/s/.git
2019-02-12T06:55:20.3330331Z INFO [02/12/19 6:55:20:33] IsDynamicGitRepository: False
2019-02-12T06:55:20.3332671Z INFO [02/12/19 6:55:20:33] Returning Project Root from DotGitDirectory: /workspace/3/s/.git - /workspace/3/s
2019-02-12T06:55:20.3352748Z INFO [02/12/19 6:55:20:33] Begin: Loading version variables from disk cache
2019-02-12T06:55:20.3362024Z INFO [02/12/19 6:55:20:33] Cache file /workspace/3/s/.git/gitversion_cache/D9024F533F722C05B92F78C8F61F289F0A9FE0B2.yml not found.
2019-02-12T06:55:20.3362464Z INFO [02/12/19 6:55:20:33] End: Loading version variables from disk cache (Took: 0.92ms)
2019-02-12T06:55:20.3364513Z INFO [02/12/19 6:55:20:33] IsDynamicGitRepository: False
2019-02-12T06:55:20.3365209Z INFO [02/12/19 6:55:20:33] Returning Project Root from DotGitDirectory: /workspace/3/s/.git - /workspace/3/s
2019-02-12T06:55:20.5384237Z INFO [02/12/19 6:55:20:53] Using latest commit on specified branch
2019-02-12T06:55:20.5498945Z INFO [02/12/19 6:55:20:54] Begin: Attempting to inherit branch configuration from parent branch
2019-02-12T06:55:20.5621357Z INFO [02/12/19 6:55:20:56] HEAD is merge commit, this is likely a pull request using bug/MAA-132 as base
2019-02-12T06:55:20.6286815Z INFO [02/12/19 6:55:20:62] Begin: Finding branch source of 'bug/MAA-132'
2019-02-12T06:55:20.6417145Z INFO [02/12/19 6:55:20:64] Begin: Finding merge base between 'bug/MAA-132' and 'master'.
2019-02-12T06:55:20.6448661Z INFO [02/12/19 6:55:20:64] Found merge base of d126a3fec374f4f70695df90bde35d3f8f5d440b
2019-02-12T06:55:20.6530978Z INFO [02/12/19 6:55:20:65] Merge base of bug/MAA-132' and 'master is d126a3fec374f4f70695df90bde35d3f8f5d440b
2019-02-12T06:55:20.6531846Z INFO [02/12/19 6:55:20:65] End: Finding merge base between 'bug/MAA-132' and 'master'. (Took: 11.25ms)
2019-02-12T06:55:20.6540060Z INFO [02/12/19 6:55:20:65] Begin: Finding merge base between 'bug/MAA-132' and 'origin/master'.
2019-02-12T06:55:20.6540355Z INFO [02/12/19 6:55:20:65] Found merge base of d126a3fec374f4f70695df90bde35d3f8f5d440b
2019-02-12T06:55:20.6541092Z INFO [02/12/19 6:55:20:65] Merge base of bug/MAA-132' and 'origin/master is d126a3fec374f4f70695df90bde35d3f8f5d440b
2019-02-12T06:55:20.6541462Z INFO [02/12/19 6:55:20:65] End: Finding merge base between 'bug/MAA-132' and 'origin/master'. (Took: 0.21ms)
2019-02-12T06:55:20.7201226Z INFO [02/12/19 6:55:20:71] Multiple source branches have been found, picking the first one (master).
2019-02-12T06:55:20.7206831Z This may result in incorrect commit counting.
2019-02-12T06:55:20.7206996Z Options were:
2019-02-12T06:55:20.7207103Z master, origin/master
2019-02-12T06:55:20.7207643Z INFO [02/12/19 6:55:20:71] End: Finding branch source of 'bug/MAA-132' (Took: 91.56ms)
2019-02-12T06:55:20.7217200Z INFO [02/12/19 6:55:20:72] Begin: Getting branches containing the commit 'd126a3fec374f4f70695df90bde35d3f8f5d440b'.
2019-02-12T06:55:20.7217564Z INFO [02/12/19 6:55:20:72] Trying to find direct branches.
2019-02-12T06:55:20.7227208Z INFO [02/12/19 6:55:20:72] No direct branches found, searching through tracked branches.
...
2019-02-12T06:55:20.9184469Z INFO [02/12/19 6:55:20:91] Searching for commits reachable from 'master'.
2019-02-12T06:55:20.9185263Z INFO [02/12/19 6:55:20:91] The branch 'master' has a matching commit.
2019-02-12T06:55:20.9186533Z INFO [02/12/19 6:55:20:91] Searching for commits reachable from 'origin/master'.
2019-02-12T06:55:20.9187115Z INFO [02/12/19 6:55:20:91] The branch 'origin/master' has a matching commit.
2019-02-12T06:55:20.9188683Z INFO [02/12/19 6:55:20:91] End: Getting branches containing the commit 'd126a3fec374f4f70695df90bde35d3f8f5d440b'. (Took: 197.40ms)
2019-02-12T06:55:20.9191330Z INFO [02/12/19 6:55:20:91] Begin: Getting branches containing the commit '8c67860532d18571431936267369df202c5ca5cd'.
2019-02-12T06:55:20.9192356Z INFO [02/12/19 6:55:20:91] Trying to find direct branches.
2019-02-12T06:55:20.9192945Z INFO [02/12/19 6:55:20:91] No direct branches found, searching through tracked branches.
...
2019-02-12T06:55:21.0532772Z INFO [02/12/19 6:55:21:05] Searching for commits reachable from 'origin/master'.
2019-02-12T06:55:21.1170042Z INFO [02/12/19 6:55:21:11] The branch 'origin/master' has no matching commits.
2019-02-12T06:55:21.1170596Z INFO [02/12/19 6:55:21:11] End: Getting branches containing the commit '8c67860532d18571431936267369df202c5ca5cd'. (Took: 197.75ms)
2019-02-12T06:55:21.1197404Z INFO [02/12/19 6:55:21:11] Found possible parent branches: master, origin/master
2019-02-12T06:55:21.1244944Z WARN [02/12/19 6:55:21:12] Failed to inherit Increment branch configuration, ended up with: master, origin/master
This is the exact issue I'm facing. It recursively calls itself until it overflows.
We are seeing the same issue now with no configuration changes on our side. It only started recently.
Which version of GitVersion are you experiencing this with? Have you tried upgrading to the latest v5 beta?
For our part, we are using the latest available on Azure DevOps which is version 4.* or so it says. We had to put in an option to not look further back in the history than Jan 01 '19 for ours and then it started working again. Not sure why it would choke like that on previous commits.
It's very hard to know without being able to reproduce the problem. A public repository portraying this issue would help immensely.
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.
I solved this issue in Azure DevOps by configuring the pull-request matching regex to catch the ADO PR branch #'s and to not increment.
pull-request:
mode: ContinuousDelivery
tag: PullRequest
increment: **None**
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
regex: (pull|pull\-requests|pr|[0-9]+)[/-]
tracks-release-branches: false
is-release-branch: false
It's a quick hack for sure and won't account for everything probably needed.
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.
Great find, @samjwest. A PR that adjusts the default regex of GitVersion to also match AzDO's out of the box would be welcome.
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.
I'm also hitting this on my pipeline Azure pipeline (using GitHub as source) I'm currently trying to update the GitVersionTask in this pull request from 5.1.3 to 5.3.3.
But don't understand why or how exactly the workaround would fix it. Currently don't have any custom configuration to pull-requests defined on my yml file and doing /showconfig shows like this:
pull-request:
mode: ContinuousDelivery
tag: PullRequest
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)'
track-merge-target: false
regex: ^(pull|pull\-requests|pr)[/-]
source-branches:
- develop
- master
- release
- feature
- support
- hotfix
tracks-release-branches: false
is-release-branch: false
is-mainline: false
pre-release-weight: 30000
But in the builds it fails with
Failed to inherit Increment branch configuration, ended up with: master, origin/master
I don't want to turn off the increment :/
Even with the warnings it appears to be setting the version numbers correctly
My build log:
2020-05-18T22:03:11.0408861Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:03] Branch from build environment: refs/pull/13/merge
2020-05-18T22:03:11.0686339Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:06] Project root is: D:\a\1\s\
2020-05-18T22:03:11.0687769Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:06] DotGit directory is: D:\a\1\s\.git
2020-05-18T22:03:11.0690537Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:06] Begin: Normalizing git directory for branch 'refs/pull/13/merge'
2020-05-18T22:03:11.1043927Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:10] One remote found (origin -> '**removed from log**').
2020-05-18T22:03:11.1089344Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:10] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2020-05-18T22:03:11.1168343Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:11] Updating local branch refs/heads/pull/13/merge to match ref refs/pull/13/merge
2020-05-18T22:03:11.1539485Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:15] Skipping update of 'refs/remotes/origin/libs-update' as it already matches the remote ref.
2020-05-18T22:03:11.1555432Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:15] Skipping update of 'refs/remotes/origin/master' as it already matches the remote ref.
2020-05-18T22:03:11.1557234Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:15] HEAD points at branch 'refs/heads/pull/13/merge'.
2020-05-18T22:03:11.1577299Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:15] End: Normalizing git directory for branch 'refs/pull/13/merge' (Took: 88.03ms)
2020-05-18T22:03:11.1654875Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:16] Begin: Loading version variables from disk cache
2020-05-18T22:03:11.1658605Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:16] Begin: Deserializing version variables from cache file D:\a\1\s\.git\gitversion_cache\F23D67B03F5BB4933DC674BC4E6FA175EBB18D8C.yml
2020-05-18T22:03:11.2323647Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:23] End: Deserializing version variables from cache file D:\a\1\s\.git\gitversion_cache\F23D67B03F5BB4933DC674BC4E6FA175EBB18D8C.yml (Took: 66.45ms)
2020-05-18T22:03:11.2328379Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:23] End: Loading version variables from disk cache (Took: 67.03ms)
2020-05-18T22:03:11.2723000Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:27] Using latest commit on specified branch
2020-05-18T22:03:11.2844315Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:28] Begin: Attempting to inherit branch configuration from parent branch
2020-05-18T22:03:11.2923354Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:29] HEAD is merge commit, this is likely a pull request using libs-update as base
2020-05-18T22:03:11.2964417Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:29] Begin: Finding branch source of 'libs-update'
2020-05-18T22:03:11.3097760Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:30] Begin: Finding merge base between 'libs-update' and 'master'.
2020-05-18T22:03:11.3147375Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:31] Found merge base of 890ae261d8e9b4dceca6bb7fd249e8e7302400d6
2020-05-18T22:03:11.3242722Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:32] Merge base of libs-update' and 'master is 890ae261d8e9b4dceca6bb7fd249e8e7302400d6
2020-05-18T22:03:11.3244083Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:32] End: Finding merge base between 'libs-update' and 'master'. (Took: 14.74ms)
2020-05-18T22:03:11.3248831Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:32] Begin: Finding merge base between 'libs-update' and 'origin/master'.
2020-05-18T22:03:11.3250270Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:32] Found merge base of 890ae261d8e9b4dceca6bb7fd249e8e7302400d6
2020-05-18T22:03:11.3252139Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:32] Merge base of libs-update' and 'origin/master is 890ae261d8e9b4dceca6bb7fd249e8e7302400d6
2020-05-18T22:03:11.3253530Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:32] End: Finding merge base between 'libs-update' and 'origin/master'. (Took: 0.49ms)
2020-05-18T22:03:11.3333287Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:33] Multiple source branches have been found, picking the first one (master).
2020-05-18T22:03:11.3334168Z This may result in incorrect commit counting.
2020-05-18T22:03:11.3334556Z Options were:
2020-05-18T22:03:11.3334927Z master, origin/master
2020-05-18T22:03:11.3335827Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:33] End: Finding branch source of 'libs-update' (Took: 37.00ms)
2020-05-18T22:03:11.3378266Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:33] Begin: Getting branches containing the commit '890ae261d8e9b4dceca6bb7fd249e8e7302400d6'.
2020-05-18T22:03:11.3379481Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:33] Trying to find direct branches.
2020-05-18T22:03:11.3380524Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:33] No direct branches found, searching through all branches.
2020-05-18T22:03:11.3381226Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:33] Searching for commits reachable from 'master'.
2020-05-18T22:03:11.3422156Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] The branch 'master' has a matching commit.
2020-05-18T22:03:11.3424574Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] Searching for commits reachable from 'origin/master'.
2020-05-18T22:03:11.3429224Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] The branch 'origin/master' has a matching commit.
2020-05-18T22:03:11.3431836Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] End: Getting branches containing the commit '890ae261d8e9b4dceca6bb7fd249e8e7302400d6'. (Took: 5.31ms)
2020-05-18T22:03:11.3433454Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] Begin: Getting branches containing the commit '3b3a7941964f84af96090e1af812dafca785b243'.
2020-05-18T22:03:11.3434762Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] Trying to find direct branches.
2020-05-18T22:03:11.3435959Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] No direct branches found, searching through all branches.
2020-05-18T22:03:11.3437226Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] Searching for commits reachable from 'master'.
2020-05-18T22:03:11.3453845Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] The branch 'master' has no matching commits.
2020-05-18T22:03:11.3455721Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] Searching for commits reachable from 'origin/master'.
2020-05-18T22:03:11.3494824Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] The branch 'origin/master' has no matching commits.
2020-05-18T22:03:11.3497004Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] End: Getting branches containing the commit '3b3a7941964f84af96090e1af812dafca785b243'. (Took: 6.30ms)
2020-05-18T22:03:11.3499140Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:34] Found possible parent branches: master, origin/master
2020-05-18T22:03:11.3527079Z 1>C:\Users\VssAdministrator\.nuget\packages\gitversiontask\5.3.3\build\GitVersionTask.targets(10,9): warning : 2020-05-18 22:03:11 WARN [05/18/20 22:03:11:35] Failed to inherit Increment branch configuration, ended up with: master, origin/master
2020-05-18T22:03:11.3529381Z C:\Users\VssAdministrator\.nuget\packages\gitversiontask\5.3.3\build\GitVersionTask.targets(10,9): warning : Falling back to master branch config
2020-05-18T22:03:11.3531067Z C:\Users\VssAdministrator\.nuget\packages\gitversiontask\5.3.3\build\GitVersionTask.targets(10,9): warning :
2020-05-18T22:03:11.3532390Z 2020-05-18 22:03:11 INFO [05/18/20 22:03:11:35] End: Attempting to inherit branch configuration from parent branch (Took: 68.40ms)```
Are there any future plans in looking into this? I see it was marked stale by the bot, but this is still an issue for myself.
@owns, as I don't use AzDO myself, nothing is going to happen until someone who actually needs this submits a PR, as noted in https://github.com/GitTools/GitVersion/issues/1579#issuecomment-587471184.
@asbjornu Thank you for clarifying.
@asbjornu can you see my comment? Why does it happen in my configuration?
I don't see how the regex change would help as it is actually matching the pull request rule already as it can be seen by the name of the version it generated.
@joaorosado, I think the real problem here is AzDO failing on warnings being logged and not on the exit code of the executing process. Or is the exit code of GitVersion actually non-zero in this case? Anyhow, if changing the logged statement from Warning
to Info
helps, I'm not opposed to changing it.
https://github.com/GitTools/GitVersion/blob/088892fce63768f95c8a9475e9b866121ba3ca9a/src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs#L138
We just need a PR from someone who can verify that this indeed fixes the problem.
Yes, like you said, it doesn't cause the pipeline itself to fail, only marks all builds with warnings.
I can give it a try to fix it, but doesn't look like changing that line will be enough.
The "WARN [05/18/20 22:03:11:35] Failed to inherit Increment branch configuration, ended up with: master, origin/master" looks like the real culprit here. Also this happens also on builds in Tags on master (exact same messages that I shown above)
I've just experienced a similar warning on a local build, directly in my VS2019 output (speaking of develop instead of master, but otherwise, same symptom). I have no GitVersion configuration at all. I do not have time right now to dig into this, but I'll try to have a look anyway (my setup does not involve Azure DevOps, so should be easier to reproduce...)
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.
It's very hard to know without being able to reproduce the problem. A public repository portraying this issue would help immensely.
Hi, I am really wondering about this issue, I use the GitVersionTask and get this same warning in my build logs, both in PR builds and in feature branch builds. However, I saw this exact same warning on the build of GitVersion (The link points to the exact warning...).
It can be argued that this isn't Azure DevOps, but to me it looks the same as the issue that is described. However, the version numbering is correct (at least for my project), so I really think this shouldn't be a warning, but a info.
Another solution might be to ignore local branches from the calculations and only use a specified remote branch?
This issue is all about the following line within the class BranchConfigurationCalculator
:
this.log.Info($"No branch configuration found for branch {targetBranch}, falling back to default configuration");
The branch configuration system and the way how the branch inheritance happend has been changed. The hole class has been removed with the actual development initiaitives in version 6.x. Thus I'm going to close this issue. Please re-open this issue if this problem sill persists. Thank you very much.
:tada: This issue has been resolved in version 6.0.0-beta.2 :tada: The release is available on:
Your GitReleaseManager bot :package::rocket: