Branch specific version

oliver's Avatar

oliver

05 Jul, 2018 06:59 AM

I would like to use

version: 1.0.{build}-{branch}
in all branches except for master, where I want it to be
version: 1.0.{build}
is this possible?
  1. Support Staff 1 Posted by Owen McDonnell on 05 Jul, 2018 03:01 PM

    Owen McDonnell's Avatar

    Sure. It's documented here
    I think something like this should work...

    version: 1.0.{build}-{branch}
    ...
    for:
    - 
      branches:
        only:
          - master
      version: 1.0.{build}
    
  2. 2 Posted by oliver on 06 Jul, 2018 08:31 AM

    oliver's Avatar

    That is perfect. Thank you Owen.

    Just one more thing, as it is related:
    does do_not_increment_build_number: true work with this as well?

  3. Support Staff 3 Posted by Owen McDonnell on 06 Jul, 2018 05:43 PM

    Owen McDonnell's Avatar

    Yes, that should work.

  4. 4 Posted by oliver on 09 Jul, 2018 01:27 PM

    oliver's Avatar

    I have this config:

      version: 0.1.{build}
    
      environment:
          PSGalleryAPIKey:
              secure: xxxxx
          access_token:
              secure: xxxxx
          matrix:
              - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
              # waiting on https://github.com/RamblingCookieMonster/BuildHelpers/pull/60
              # - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4
              - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
                PowershellVersion: "6.0.0"
              - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
                PowershellVersion: "6.0.0"
    
      # Fail the Build with the first Job that failes
      matrix:
          fast_finish: true
      # Don't rebuild when a release is tagged on GitHub
      skip_tags: true
      # Do not increase AppVeyor's build number
      do_not_increment_build_number: true
      # Logic for skipping CI is in the build script
    
      for:
      -
          branches:
              only:
                  - master
          do_not_increment_build_number: false
    
      init:
          - ps: |
              if (-not ($env:PowershellVersion)) {$env:PowershellVersion = "5.1"}
              if (([version]$env:PowershellVersion).Major -ge 6) {$env:posh = "pwsh"} else {$env:posh = "powershell"}
              Add-Content (Join-Path $Home ".git-credentials") "https://$($env:access_token):x-oauth-basic@github.com`n"
          - git config --global credential.helper "store --file ~/.git-credentials"
          - git config --global user.email "[email blocked]"
          - git config --global user.name "AtlassianPS automation"
    
      install:
          - ps: '& $env:posh -File "./Tools/setup.ps1"'
    
      build_script:
          - ps: '& $env:posh -Command "Invoke-Build"'
    
      # on_failure:
          # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
    

    I get the following error

    Error parsing appveyor.yml: Invalid setting or section: do_not_increment_build_number (Line: 29, Column: 5) on line

      do_not_increment_build_number: true
    

    and if I comment that out, I get the same error on:

      for:
      -
          branches:
              only:
                  - master
          do_not_increment_build_number: false
    
  5. Support Staff 5 Posted by Owen McDonnell on 09 Jul, 2018 04:05 PM

    Owen McDonnell's Avatar

    Try putting do_not_increment_build_number: inside a pull_requests: key, like this,

    for:
    - 
      branches:
        only: 
         - master
      pull_requests:
        do_not_increment_build_number: true
    
  6. 6 Posted by oliver on 09 Jul, 2018 04:55 PM

    oliver's Avatar

    Thank you, Owen - that works. But is not what I am trying to do.

    This will only have Pull Request to have a random hash appended to the version, so that the build number is not increased.
    I want all commits of all branches to behave like that. With the exception of the master branch - master should increase the build number

  7. Support Staff 7 Posted by Ilya Finkelshte... on 09 Jul, 2018 09:49 PM

    Ilya Finkelshteyn's Avatar

    We created this workaround for you. It is a kind of hack but should work.

  8. 8 Posted by oliver on 10 Jul, 2018 07:34 AM

    oliver's Avatar

    I really appreciate this, Owen & Ilya.
    I will use that.

    Is this something AppVeyor would like to support as a feature?
    Should I create a github issue asking for this feature (as a non-workaround)?

  9. Support Staff 9 Posted by Ilya Finkelshte... on 10 Jul, 2018 07:58 PM

    Ilya Finkelshteyn's Avatar

    Sure, feel free to add GitHub issue. However we need to see how many people will vote for it.

    Alternative solution by the way: use separate AppVeyor project for master and separate for other branches.

  10. 10 Posted by oliver on 10 Jul, 2018 08:17 PM

    oliver's Avatar

    oh! I like this better. Thanks!

  11. oliver closed this discussion on 10 Jul, 2018 08:17 PM.

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