GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

[Feature] provide an option to choose which version type use to update Build.BuildNumber

Open quasarea opened this issue 4 years ago • 3 comments

I'm not entirely sure how it works, but when called from azure devops it updates pipeline version to current "FullSemVer"

I suspect it has to do with /output buildsystem and generated yml file, that is somehow gets propagated into Build.BuildNumber variable later on.

Currently there is no way of deciding on format of version and it would be great to be able i.e. to use SemVer rather then FullSemVer

Initially created at https://github.com/GitTools/actions/issues/318 but it seems its handled by gitversion itself

quasarea avatar Feb 02 '21 13:02 quasarea

This is a great suggestion, but I think, unfortunately, it points to the need for GitVersion to do less. Having to change GitVersion in order to have the AzDO Task change its behavior indicates that we have drawn the wrong boundaries around the different moving parts of our code and that the architecture needs to change.

Ideally, GitVersion should only produce version variables and then an AzDO Task or any other implementation of GitVersion can take these version variables and do whatever it pleases with them without having to change anything within GitVersion itself. #2262 and #2275 deals with this refactoring.

Introducing a configuration property in GitVersion.yml regarding this feels very wrong to me, as the configuration belongs in the AzDO Task. I'm not sure how we can fix this before we get v6 out the door.

asbjornu avatar Feb 02 '21 14:02 asbjornu

I agree that would be a great addition, but in version 6 . There we have a clear separation of the version calculation and output, Maybe we add it to 6.0.0 milestone

arturcic avatar Feb 02 '21 14:02 arturcic

Workaround:

      - task: gitversion/execute@0
        displayName: Calculating version
        inputs:
          additionalArguments: /output file /outputfile $(Build.SourcesDirectory)\GitVersion.json

      - pwsh: |
          $GitVersion = ConvertFrom-Json -AsHashtable ( Get-Content -Raw -Path 'GitVersion.json' )
          Write-Host "##vso[build.updatebuildnumber]$($GitVersion.SemVer)"
        displayName: 'Update Build.BuildNumber'

quasarea avatar Feb 25 '21 09:02 quasarea

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.

github-actions[bot] avatar May 20 '23 11:05 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions

github-actions[bot] avatar Jun 20 '23 11:06 github-actions[bot]