Minver not working on Azure devops - sets the default version 0.0.0-alpha.0

274 Views Asked by At

When version tag is set on last commit it works ok. But when version tag is set on some of parent commit the resulting version is 0.0.0-alpha.0

1

There are 1 best solutions below

0
On

The problem is with the way azure devops does checkout. It fetches only last commit (depth=1). Log from devops checkout:

git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1 .....

and minver cannot infer version from only last commit. The fix is to set appropriate depth in azure-pipelines.yml:

steps:
- checkout: self
  fetchDepth: 50  # the depth of commits to ask Git to fetch
  fetchTags: true

Now log looks good:

git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=50

and minver does its job.