Branch specific version

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. 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. 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. Yes, that should work.

  4. 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. 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. 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. We created this workaround for you. It is a kind of hack but should work.

  8. 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. 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. oh! I like this better. Thanks!

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

  12. oliver re-opened this discussion on 05 Aug, 2018 08:19 PM

  13. Hey, Ilya...
    This setup didn't quite work out as I hoped.
    I would appreciate it, if you could take a look and point out where my mistake is.

    location of appveyor.yml: <projectroot>/Tools/appveyor.yml
    config in the UI: screenshot: vivaldi_2018-08-05_22-21-29.png

    config in the UI for the branches:
    AppVeyor project AtlassianPS.Configuration: vivaldi_2018-08-05_22-22-52.png
    AppVeyor project AtlassianPS.Configuration@next: vivaldi_2018-08-05_22-23-34.png

    and this commit triggered both to run the CI:
    * https://ci.appveyor.com/project/AtlassianPS/atlassianps-configurati... * https://ci.appveyor.com/project/AtlassianPS/atlassianps-configurati...

  14. The screenshots you have for different branches UI config are not settings that are shared between UI and yaml file configuration. You can see that list here.

    Rather, you should have

    branches:
      only:
        - master
    
    or
    branches: 
      except:
        - master
    
    in your config file.
  15. So I would have to have 2 different appveyor.yml files with exactly the same content except for the branches: block?

  16. Yes, and each project pointing to a different config file (or let one of the projects use 'default' config file and location).

  17. great! thanks

  18. oliver closed this discussion on 06 Aug, 2018 04:31 PM.

  19. oliver re-opened this discussion on 06 Aug, 2018 04:31 PM

  20. oliver closed this discussion on 06 Aug, 2018 04:31 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