Reset the build number automatically (yml)

Yuki Hyou's Avatar

Yuki Hyou

16 May, 2014 06:41 AM

Hi guys,

I'm using the yml config at the moment, and trying to get the build numbers to reset once the major/minor versions are incremented. I know I can go into the web interface and reset it manually, but that is tedious. I want it to auto-reset when I manually change the major/minor numbers in my yml:

1.0.{0}
1.0.{1}
1.0.{2}
1.0.{3}
1.1.{0}

I understand that if you try to use a number that's already taken (not unique), the number will be auto incremented to the next available unique entry. If this is the case, could I simply specify something in my yml to reset the build number to 0, so it will start at 0 on each build, which should result in the functionality above?

I've searched the forum and Google, as well as looked through the documentation, but can't see any way to reset the build count without using the web interface.

Please advise.

  1. Support Staff 1 Posted by Feodor Fitsner on 16 May, 2014 11:57 PM

    Feodor Fitsner's Avatar

    There is a better way setting build number as you want: https://www.appveyor.com/docs/build-worker-api/#update-build-details

  2. 2 Posted by JyeGuru on 17 May, 2014 02:04 AM

    JyeGuru's Avatar

    This seems to be a way of setting the whole version number myself, which I don't particularly want to do. I am happy with using the default 'increment by one' version numbers in these projects, at least for now, and simply changing the version header in the appveyor.yml when pushing updates hotfixes/versions/etc.

    In my post, I am referring to this particular comment:

    You can have "through" builds numbering in which major and minor parts of the version are changing and the build number is never reset or you can reset the build number for every new version. -- http://www.appveyor.com/docs/build-configuration#build-versioning

    It would seem to indicate that there is a way to choose this behavior, which would be perfect, however I can't find anything that would suggest any entries for appveyor.yml that would influence the build number generation.

  3. Support Staff 3 Posted by Feodor Fitsner on 17 May, 2014 10:43 PM

    Feodor Fitsner's Avatar

    Oh, that phrase means you can reset build number on UI.

  4. 4 Posted by JyeGuru on 18 May, 2014 01:16 AM

    JyeGuru's Avatar

    Ah, I see. In that case, is it possible request adding a 'reset build number to zero' option into the yml parser?

  5. Support Staff 5 Posted by Feodor Fitsner on 18 May, 2014 02:12 AM

    Feodor Fitsner's Avatar

    Sure, what would be the trigger to reset build number to zero then?

  6. 6 Posted by JyeGuru on 18 May, 2014 02:21 AM

    JyeGuru's Avatar

    How about something simple like a new entry:

    buildnumber: through|reset|force: #

    This is presuming that it would respect the 'if not unique, then find lowest unique number' behavior that resetting it through the web interface would.

    through = current behavior reset = try {build}=1 and increment until unique version found force: # = try {build}=# and error if version not unique

    Personally, I would just leave it on reset which would result in the numbering scheme in my first post (with the exception of {0} because I noticed after posting that {1} is the lowest value), however this should cover all use cases?

  7. Support Staff 7 Posted by Feodor Fitsner on 18 May, 2014 06:58 PM

    Feodor Fitsner's Avatar

    Well, that's an interesting suggestion and I think it's pretty doable. I'm going to add it to issues list. Thanks!

    - Feodor

  8. 8 Posted by JyeGuru on 20 May, 2014 06:58 AM

    JyeGuru's Avatar

    Thanks! :)

  9. 9 Posted by micdenny on 19 Aug, 2015 02:46 PM

    micdenny's Avatar

    I don't see the issue, what about this feature?

  10. 10 Posted by Chris Simmons on 19 Feb, 2016 12:25 AM

    Chris Simmons's Avatar

    Hello Feodor, can you tell us if this feature will be added? I'm using the build number as my patch number for semantic versioning and would love it if AppVeyor would be able to detec a new major or minor version and reset the build number to 0. I think Yuki Hyou's solution above would be perfect, except for reset, the initially-tried value would be 0 and not 1.

  11. Support Staff 11 Posted by Feodor Fitsner on 21 Feb, 2016 01:51 AM

    Feodor Fitsner's Avatar

    We've added a new REST API method to update next build number: http://www.appveyor.com/docs/api/projects-builds#update-project-bui...

  12. 12 Posted by Benjamin Abt on 21 Sep, 2016 07:56 PM

    Benjamin Abt's Avatar

    Is it possible right now to auto reset the build number? a rest api call is not automatically integrateable in open source projects.

    My request:
    If I increase Major or Minor the Build number should be reset automatically to 0.
    Optional property of yml like Yuki Hyou here said in 2014.

  13. 13 Posted by bazzilic on 19 Jun, 2017 09:38 AM

    bazzilic's Avatar

    I would also like this feature to be available through YAML config

  14. 14 Posted by Daniel Wilches on 07 Jul, 2017 08:36 PM

    Daniel Wilches's Avatar

    The optional property in the yml would be useful to me too. We already manipulate the yml when doing releases to force the major/minor version number, but doing an API call means we need to code an extra step somewhere in our pipeline.

    For future generations though ...

  15. 15 Posted by ericnewton76 on 27 Dec, 2017 09:55 PM

    ericnewton76's Avatar

    +1 for me.

    Although this would work perfectly for many:

    appveyor.yml:
    buildnumber:
    #reset build number on a tag build
      resetOnTag: 0

  16. 16 Posted by ericnewton76 on 27 Dec, 2017 09:58 PM

    ericnewton76's Avatar

    Could this be added to the Powershell cmdlets?

    sample appveyor yml:
    on_init:
    - ps: if($env.APPVEYOR_REPO_TAG -eq "true") { Set-BuildNumber 0 }

  17. 17 Posted by niveus_everto on 22 Mar, 2018 04:37 PM

    niveus_everto's Avatar

    Any updates on this?

  18. 18 Posted by salaros on 17 Jun, 2018 04:04 PM

    salaros's Avatar

    @niveus_everto

    Hey, I reset the build number of one of my projects in order to have -preview1, -preview2 and so on
    on the next non-tagged builds, until the next tagged build.

    I think you can adapt it for your needs:

    environment:
      APPVEYOR_TOKEN:
        secure: XxxxxxxxxxxxxxxxxxXXxxxxxxxxxxxxxxxx=
    
    after_deploy:
      - ps: script-below.ps1
    

    Power shell script:

    if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
        $headers = @{
            "Authorization" = "Bearer $env:APPVEYOR_TOKEN"
            "Content-type" = "application/json"
            "Accept" = "application/json"
        }
        $build = @{
            nextBuildNumber = 1
        }
        $json = $build | ConvertTo-Json
        Invoke-RestMethod -Method Put "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/build-number" -Body $json -Headers $headers
    }
    

    P.S. Please note APPVEYOR_TOKEN variable contains an encrypted API token. You can find your AppVeyor API key here

  19. Owen McDonnell closed this discussion on 27 Jun, 2019 05:24 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac