1

I've got a repo with multiple solutions on in. I created a pipeline for a specific one and linked to a specific gitversion.yml file to calculate version numbers by specific commit messages. I added the ignore-commits-before tag to force version numbers to reset from 0.1.0.

This works fine in local with gitversion (v. 5.8.1) installed.

However versioning from devops (GitVersion.Tool\5.3.7) pipeline does not give same results and seems is unable to ignore previous commits.

Here is the gitversion.yml file

mode: Mainline
major-version-bump-message: '\+saa:\s?(breaking|major)'
minor-version-bump-message: '\+saa:\s?(feature|minor)'
patch-version-bump-message: '\+saa:\s?(fix|patch)'
commit-message-incrementing: Enabled
branches:
  master:
    tag: ci
    increment: None
  pull-request:
    increment: None
ignore:
  commits-before: 2021-11-20T14:00:00
  sha: 
    - 0f016fd7b149c285a78c37ef7291bd75836231c8 
merge-message-formats: {}

Calling gitversion from local it ignores commits before date and the output is

gitversion  /config .\customer-saa\GitVersion.yml
>  "SemVer": "0.1.450-saa-51815-versioning.5",

Called from DevOps the output is

\_tool\GitVersion.Tool\5.3.7\x64\dotnet-gitversion.exe C:/agent/_work/160/s /output json /output buildserver /config C:\agent\_work\160\s\customer-saa\GitVersion.yml
>  "SemVer":"1.2.182-saa-51815-versioning.5",

And here'is a the log (simplified)

2021-11-21T19:40:35.6433364Z ##[section]Starting: Calculating SemVer
2021-11-21T19:40:35.6603918Z ==============================================================================
2021-11-21T19:40:35.6604166Z Task         : Execute GitVersion Task
2021-11-21T19:40:35.6604421Z Description  : Easy Semantic Versioning (http://semver.org) for projects using Git
2021-11-21T19:40:35.6604637Z Version      : 0.9.11
2021-11-21T19:40:35.6604799Z Author       : GitTools Contributors
2021-11-21T19:40:35.6605058Z Help         : See the [documentation](https://gitversion.net/docs/) for help
2021-11-21T19:40:35.6605316Z ==============================================================================
2021-11-21T19:40:36.0855947Z Command: dotnet-gitversion C:/agent/_work/160/s /output json /output buildserver /config C:\agent\_work\160\s\customer-saa\GitVersion.yml
2021-11-21T19:40:36.0878401Z [command]C:\agent\_work\_tool\GitVersion.Tool\5.3.7\x64\dotnet-gitversion.exe C:/agent/_work/160/s /output json /output buildserver /config C:\agent\_work\160\s\customer-saa\GitVersion.yml
2021-11-21T19:40:39.2658808Z INFO [11/21/21 20:40:36:83] Working directory: C:/agent/_work/160/s
2021-11-21T19:40:39.2659551Z INFO [11/21/21 20:40:36:92] Branch from build environment: refs/heads/saa/51815-versioning
2021-11-21T19:40:39.2659960Z INFO [11/21/21 20:40:36:92] Project root is: C:\agent\_work\160\s\
2021-11-21T19:40:39.2660650Z INFO [11/21/21 20:40:36:92] DotGit directory is: C:\agent\_work\160\s\.git
2021-11-21T19:40:39.2661300Z INFO [11/21/21 20:40:36:92] Begin: Normalizing git directory for branch 'refs/heads/saa/51815-versioning'
2021-11-21T19:40:39.2661841Z   INFO [11/21/21 20:40:36:95] One remote found (origin -> 'https://xxxxx').
2021-11-21T19:40:39.2662445Z   INFO [11/21/21 20:40:36:95] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2021-11-21T19:40:39.2663022Z   INFO [11/21/21 20:40:36:96] Updating local branch refs/heads/saa/51815-versioning to point at df0be162c0ec4a813fd35124c1696e9fcd3b15ac
2021-11-21T19:40:39.2663560Z   INFO [11/21/21 20:40:37:33] Creating local branch from remote tracking 'refs/remotes/origin/df0be162c0ec4a813fd35124c1696e9fcd3b15ac'.
2021-11-21T19:40:39.2667521Z   INFO [11/21/21 20:40:37:37] Updating local ref 'refs/heads/master' to point at cc53ce41a20abc1952d3c12d83c9ad26d8237f7f.
2021-11-21T19:40:39.2667954Z   INFO [11/21/21 20:40:37:38] Skipping update of 'refs/remotes/origin/ocq/upload-senza-resize' as it already matches the remote ref.
2021-11-21T19:40:39.2668375Z   INFO [11/21/21 20:40:37:38] Skipping update of 'refs/remotes/origin/release/ali/1.0' as it already matches the remote ref.
2021-11-21T19:40:39.2668804Z   INFO [11/21/21 20:40:37:39] Skipping update of 'refs/remotes/origin/release/int/1.2' as it already matches the remote ref.
2021-11-21T19:40:39.2669232Z   INFO [11/21/21 20:40:37:39] Updating local ref 'refs/heads/release/int/1.3' to point at acce83180ecfde7304c1f488d6fb2fdae538dc7e.
2021-11-21T19:40:39.2669649Z   INFO [11/21/21 20:40:37:40] Skipping update of 'refs/remotes/origin/release/ocq/1.5' as it already matches the remote ref.
2021-11-21T19:40:39.2670074Z   INFO [11/21/21 20:40:37:41] Skipping update of 'refs/remotes/origin/release/ocq/1.6' as it already matches the remote ref.
2021-11-21T19:40:39.2671873Z   INFO [11/21/21 20:40:37:41] Skipping update of 'refs/remotes/origin/release/ver/1.4.0' as it already matches the remote ref.
2021-11-21T19:40:39.2672294Z   INFO [11/21/21 20:40:37:42] Creating local branch from remote tracking 'refs/remotes/origin/saa/51811-feature-toggle'.
2021-11-21T19:40:39.2672719Z   INFO [11/21/21 20:40:37:44] Skipping update of 'refs/remotes/origin/ver/28320-selenium-test' as it already matches the remote ref.
2021-11-21T19:40:39.2673357Z   INFO [11/21/21 20:40:37:44] HEAD points at branch 'refs/heads/saa/51815-versioning'.
2021-11-21T19:40:39.2673753Z   INFO [11/21/21 20:40:37:45] End: Normalizing git directory for branch 'refs/heads/saa/51815-versioning' (Took: 528.27ms)
2021-11-21T19:40:39.2674228Z   INFO [11/21/21 20:40:37:47] Begin: Loading version variables from disk cache
2021-11-21T19:40:39.2674627Z     INFO [11/21/21 20:40:37:47] Cache file C:\agent\_work\160\s\.git\gitversion_cache\B117CA14696791C9927D1ABF850C2C808BFB27E3.yml not found.
2021-11-21T19:40:39.2675058Z   INFO [11/21/21 20:40:37:47] End: Loading version variables from disk cache (Took: 1.28ms)
2021-11-21T19:40:39.2675383Z   INFO [11/21/21 20:40:37:71] Using latest commit on specified branch
2021-11-21T19:40:39.2675747Z   INFO [11/21/21 20:40:37:72] No branch configuration found for branch saa/51815-versioning, falling back to default configuration
2021-11-21T19:40:39.2676130Z   INFO [11/21/21 20:40:37:73] Begin: Attempting to inherit branch configuration from parent branch
2021-11-21T19:40:39.2676481Z     INFO [11/21/21 20:40:37:74] Begin: Finding branch source of 'saa/51815-versioning'
2021-11-21T19:40:39.2676840Z       INFO [11/21/21 20:40:37:76] Begin: Finding merge base between 'saa/51815-versioning' and 'master'.
2021-11-21T19:40:39.2677193Z         INFO [11/21/21 20:40:37:76] Found merge base of 0f016fd7b149c285a78c37ef7291bd75836231c8
2021-11-21T19:40:39.2677581Z         INFO [11/21/21 20:40:37:77] Merge base of saa/51815-versioning' and 'master is 0f016fd7b149c285a78c37ef7291bd75836231c8
2021-11-21T19:40:39.2678050Z       INFO [11/21/21 20:40:37:77] End: Finding merge base between 'saa/51815-versioning' and 'master'. (Took: 9.67ms)
[...]
2021-11-21T19:40:39.2700277Z       INFO [11/21/21 20:40:37:82] Begin: Finding merge base between 'saa/51815-versioning' and 'origin/release/ver/1.4.0'.
2021-11-21T19:40:39.2700672Z         INFO [11/21/21 20:40:37:82] Found merge base of 991045280c88b449e6f0d0354e0bdaba72885e08
2021-11-21T19:40:39.2701074Z         INFO [11/21/21 20:40:37:82] Merge base of saa/51815-versioning' and 'origin/release/ver/1.4.0 is 991045280c88b449e6f0d0354e0bdaba72885e08
2021-11-21T19:40:39.2701538Z       INFO [11/21/21 20:40:37:82] End: Finding merge base between 'saa/51815-versioning' and 'origin/release/ver/1.4.0'. (Took: 2.29ms)
2021-11-21T19:40:39.2701947Z       INFO [11/21/21 20:40:37:83] Multiple source branches have been found, picking the first one (master).
2021-11-21T19:40:39.2702261Z This may result in incorrect commit counting.
2021-11-21T19:40:39.2702455Z Options were:
2021-11-21T19:40:39.2702924Z master, origin/master, release/int/1.3, release/ocq/1.6, origin/release/int/1.3, origin/release/ocq/1.6, release/int/1.2, origin/release/int/1.2, release/ver/1.4.0, origin/release/ver/1.4.0, release/ocq/1.5, origin/release/ocq/1.5, release/ali/1.0, origin/release/ali/1.0
2021-11-21T19:40:39.2703743Z     INFO [11/21/21 20:40:37:83] End: Finding branch source of 'saa/51815-versioning' (Took: 86.78ms)
2021-11-21T19:40:39.2704255Z     INFO [11/21/21 20:40:37:83] Begin: Getting branches containing the commit '0f016fd7b149c285a78c37ef7291bd75836231c8'.
2021-11-21T19:40:39.2704625Z       INFO [11/21/21 20:40:37:83] Trying to find direct branches.
2021-11-21T19:40:39.2704957Z       INFO [11/21/21 20:40:37:83] No direct branches found, searching through all branches.
2021-11-21T19:40:39.2705394Z       INFO [11/21/21 20:40:37:83] Searching for commits reachable from 'master'.
2021-11-21T19:40:39.2705724Z       INFO [11/21/21 20:40:37:85] The branch 'master' has a matching commit.
2021-11-21T19:40:39.2706047Z       INFO [11/21/21 20:40:37:85] Searching for commits reachable from 'release/ali/1.0'.
2021-11-21T19:40:39.2706394Z       INFO [11/21/21 20:40:37:87] The branch 'release/ali/1.0' has no matching commits.
2021-11-21T19:40:39.2706783Z       INFO [11/21/21 20:40:37:87] Searching for commits reachable from 'release/int/1.2'.
2021-11-21T19:40:39.2707122Z       INFO [11/21/21 20:40:37:89] The branch 'release/int/1.2' has no matching commits.
[...]
2021-11-21T19:40:39.2729304Z     INFO [11/21/21 20:40:38:67] End: Getting branches containing the commit 'df0be162c0ec4a813fd35124c1696e9fcd3b15ac'. (Took: 422.50ms)
2021-11-21T19:40:39.2729743Z     INFO [11/21/21 20:40:38:67] Found possible parent branches: master, origin/master
2021-11-21T19:40:39.2730234Z     WARN [11/21/21 20:40:38:67] Failed to inherit Increment branch configuration, ended up with: master, origin/master
2021-11-21T19:40:39.2730569Z Falling back to master branch config
2021-11-21T19:40:39.2730911Z   INFO [11/21/21 20:40:38:67] End: Attempting to inherit branch configuration from parent branch (Took: 942.53ms)
2021-11-21T19:40:39.2731338Z   INFO [11/21/21 20:40:38:68] Running against branch: saa/51815-versioning (df0be162c0ec4a813fd35124c1696e9fcd3b15ac)
2021-11-21T19:40:39.2731695Z   INFO [11/21/21 20:40:38:68] Begin: Calculating base versions
2021-11-21T19:40:39.2732762Z     INFO [11/21/21 20:40:38:89] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2734357Z     INFO [11/21/21 20:40:38:89] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2734867Z     INFO [11/21/21 20:40:38:89] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2735347Z     INFO [11/21/21 20:40:38:89] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2735835Z     INFO [11/21/21 20:40:38:90] Found commit [df0be162c0ec4a813fd35124c1696e9fcd3b15ac] matching merge message format: Default
2021-11-21T19:40:39.2736315Z     INFO [11/21/21 20:40:38:90] Merge message 'Merge branch 'release/ver/1.2.2'': 1.2.2 with commit count source f2f314a5e87be073a2682d1204c16454bf68be16
2021-11-21T19:40:39.2736807Z     INFO [11/21/21 20:40:38:90] Merge message 'Merge branch 'release/int/1.1'': 1.1.0 with commit count source 015e42e4b0ff151a71355b8a3442de7ac94e53a1
2021-11-21T19:40:39.2737369Z     INFO [11/21/21 20:40:38:90] Merge message 'Merge branch 'release/ver/1.2.1'': 1.2.1 with commit count source c205b37fa014df520ab16f9eb7393c13469c0f0c
2021-11-21T19:40:39.2737862Z     INFO [11/21/21 20:40:38:91] Merge message 'Merge branch 'release/ver/1.2'': 1.2.0 with commit count source c564d5141df7616b29fadfcc3805c7ac32df8af6
2021-11-21T19:40:39.2738387Z     INFO [11/21/21 20:40:38:91] Merge message 'Merge branch 'release/ver/1.1'': 1.1.0 with commit count source c09ee0b84ff269c9b6020e4da608fc727475522d
2021-11-21T19:40:39.2738920Z     INFO [11/21/21 20:40:38:96] Found multiple base versions which will produce the same SemVer (1.2.2), taking oldest source for commit counting (Merge message 'Merge branch 'release/ver/1.2.2'')
2021-11-21T19:40:39.2739481Z     INFO [11/21/21 20:40:38:96] Base version used: Merge message 'Merge branch 'release/ver/1.2.2'': 1.2.2 with commit count source f2f314a5e87be073a2682d1204c16454bf68be16
2021-11-21T19:40:39.2740020Z   INFO [11/21/21 20:40:38:96] End: Calculating base versions (Took: 277.68ms)
2021-11-21T19:40:39.2740542Z   INFO [11/21/21 20:40:38:96] Begin: Using mainline development mode to calculate current version
2021-11-21T19:40:39.2740894Z     INFO [11/21/21 20:40:38:97] Found possible mainline branches: master
2021-11-21T19:40:39.2741202Z     INFO [11/21/21 20:40:39:00] Mainline for current branch is master
2021-11-21T19:40:39.2741576Z     INFO [11/21/21 20:40:39:00] Found branch merge point; choosing 0f016fd7b149c285a78c37ef7291bd75836231c8 as effective mainline tip
2021-11-21T19:40:39.2741996Z     INFO [11/21/21 20:40:39:00] Current branch (saa/51815-versioning) was branch from 0f016fd7b149c285a78c37ef7291bd75836231c8
2021-11-21T19:40:39.2742434Z     INFO [11/21/21 20:40:39:05] Direct commit on master 8ece20f67ac67d39d7f3c8cae72c534aa2e1203f incremented base versions None, now 1.2.2
2021-11-21T19:40:39.2742889Z     INFO [11/21/21 20:40:39:05] Direct commit on master 640408c70b6055b3bee3b2a3a29e683ded747a3e incremented base versions None, now 1.2.2
2021-11-21T19:40:39.2744939Z     INFO [11/21/21 20:40:39:05] Merge commit 9b49a0e3410dbefe443851bc2d862f09cab635c3 incremented base versions Patch, now 1.2.3
[...]
2021-11-21T19:40:39.2919007Z     INFO [11/21/21 20:40:39:14] Direct commit on master 0f016fd7b149c285a78c37ef7291bd75836231c8 incremented base versions None, now 1.2.181
2021-11-21T19:40:39.2919470Z     INFO [11/21/21 20:40:39:14] 5 commits found between 0f016fd7b149c285a78c37ef7291bd75836231c8 and df0be162c0ec4a813fd35124c1696e9fcd3b15ac
2021-11-21T19:40:39.2919860Z     INFO [11/21/21 20:40:39:14] Performing Patch increment for current branch 
2021-11-21T19:40:39.2920239Z   INFO [11/21/21 20:40:39:14] End: Using mainline development mode to calculate current version (Took: 178.24ms)
2021-11-21T19:40:39.2920616Z   INFO [11/21/21 20:40:39:14] Using branch name to calculate version tag
2021-11-21T19:40:39.2920957Z   INFO [11/21/21 20:40:39:14] Begin: Getting version tags from branch 'refs/heads/saa/51815-versioning'.
2021-11-21T19:40:39.2921374Z   INFO [11/21/21 20:40:39:17] End: Getting version tags from branch 'refs/heads/saa/51815-versioning'. (Took: 33.34ms)
2021-11-21T19:40:39.2921726Z   INFO [11/21/21 20:40:39:18] Begin: Creating dictionary
2021-11-21T19:40:39.2922022Z   INFO [11/21/21 20:40:39:18] End: Creating dictionary (Took: 3.64ms)
2021-11-21T19:40:39.2922497Z   INFO [11/21/21 20:40:39:19] Begin: Storing version variables to cache file C:\agent\_work\160\s\.git\gitversion_cache\B117CA14696791C9927D1ABF850C2C808BFB27E3.yml
2021-11-21T19:40:39.2923179Z   INFO [11/21/21 20:40:39:22] End: Storing version variables to cache file C:\agent\_work\160\s\.git\gitversion_cache\B117CA14696791C9927D1ABF850C2C808BFB27E3.yml (Took: 35.32ms)
2021-11-21T19:40:39.2923624Z Executing GenerateSetVersionMessage for 'AzurePipelines'.
2021-11-21T19:40:39.3262981Z Executing GenerateBuildLogOutput for 'AzurePipelines'.
2021-11-21T19:40:39.3292597Z {
2021-11-21T19:40:39.3292783Z   "Major":1,
2021-11-21T19:40:39.3292942Z   "Minor":2,
2021-11-21T19:40:39.3293118Z   "Patch":182,
[...]
2021-11-21T19:40:39.3367618Z }
2021-11-21T19:40:39.3368004Z   INFO [11/21/21 20:40:39:24] Done writing 
2021-11-21T19:40:39.3411803Z ##[section]Async Command Start: Update Build Number
2021-11-21T19:40:39.6529458Z Update build number to 1.2.182-saa-51815-versioning.5 for build 14300
2021-11-21T19:40:39.6529816Z ##[section]Async Command End: Update Build Number
2021-11-21T19:40:39.6531031Z ##[section]Finishing: Calculating SemVer

Thanks for any help

torek
  • 448,244
  • 59
  • 642
  • 775
Grappachu
  • 1,259
  • 13
  • 21

0 Answers0