Restricting project to one branch

oliver's Avatar

oliver

12 Jul, 2018 06:53 AM

Hey

After this conversation: https://help.appveyor.com/discussions/questions/22261-branch-specif...
I decided to set up 2 AppVeyor projects for one github repository:
* for master : https://ci.appveyor.com/project/AtlassianPS/atlassianps-configuration * for all others: https://ci.appveyor.com/project/AtlassianPS/atlassianps-configurati...

In order for this to work, I have to make the setting of the branch in the UI. This is a screenshot of the "master" project:

However, this AppVeyor project is also triggered when I push a commit to develop branch.
Can you help me?

  1. Support Staff 1 Posted by Owen McDonnell on 12 Jul, 2018 03:55 PM

    Owen McDonnell's Avatar

    Could you try exporting yaml from your UI settings and checking that into the master branch?

  2. 2 Posted by oliver on 12 Jul, 2018 07:13 PM

    oliver's Avatar

    Hi Owen.

    I don't understand how that could work.
    I will not be able to maintain different yaml config files between the branches.
    Or is this merely for a test purpose?

    edit:

    I just tried it with this addition to the config:

      branches:
          except:
              - master
    

    the result is in the screenshot bellow

  3. 3 Posted by oliver on 12 Jul, 2018 07:17 PM

    oliver's Avatar

    uploading file vivaldi_2018-07-12_21-15-09.png

  4. 4 Posted by oliver on 12 Jul, 2018 07:23 PM

    oliver's Avatar

    full config:

      version: 0.1.{build}
    
      environment:
          PSGalleryAPIKey:
              secure: xxxxxx
          GITHUB_ACCESS_TOKEN:
              secure: xxxxxx
          APPVEYOR_API_TOKEN:
              secure: xxxxxx
          TRAVIS_API_TOKEN:
              secure: xxxxxx
          TIMEOUT_MINS: 30
          matrix:
              - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
                PowershellVersion: "5.1"
              - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
                PowershellVersion: "6.0.2"
              - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
                PowershellVersion: "6.0.2"
    
      branches:
          except:
              - master
    
      # Fail the Build with the first Job that fails
      matrix:
          fast_finish: true
      # Don't rebuild when a release is tagged on GitHub
      skip_tags: true
      # Logic for skipping CI is in the build script
      pull_requests:
          do_not_increment_build_number: true
    
      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:GITHUB_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"
          - git config --global core.autocrlf "false"
    
      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'))
    
  5. Support Staff 5 Posted by Owen McDonnell on 12 Jul, 2018 07:40 PM

    Owen McDonnell's Avatar

    Yes, just as a test.

    I'm a little confused by your exported Yaml.
    This config setting seems to be working as it should.

    braches:
      except:
        - master
    
    but you're saying that your setting in the UI, from which you exported this is like the screenshot above (i.e. 'Only branches specified below' and not 'All except branches specified below')?
  6. 6 Posted by oliver on 12 Jul, 2018 07:44 PM

    oliver's Avatar

    I have 2 AppVeyor projects:
    1) AtlassianPS.Configuration --- which only takes branch master
    2) AtlassianPS.Configuration@next --- which takes anything but branch master

    I exported for the 2) of these.
    Here a screenshot:

  7. Support Staff 7 Posted by Owen McDonnell on 12 Jul, 2018 08:01 PM

    Owen McDonnell's Avatar

    Yes, this much i understood...
    But i'm trying to verify that the simple 'Export YAML' tab exported the exact same

    branches:
      except:
        - master
    
    for two different 'Braches to build' settings in the 'General' tab.

    If you have 'Branches to build' setting 'Only branches specified below' to master this should yield

    branches:
      only:
        - master
    
  8. 8 Posted by oliver on 12 Jul, 2018 08:04 PM

    oliver's Avatar

    Here both side by side:

  9. Support Staff 9 Posted by Owen McDonnell on 12 Jul, 2018 09:04 PM

    Owen McDonnell's Avatar

    Ok, I think we got out of sync earlier when i asked you to commit appveyor.yml as a test I meant to check it into the master branch not add that config to existing appveyor.yml in develop branch.

    Anyway, my colleague pointed me to this answer he gave to someone with the same problem you're facing.

    The summary is that the appveyor.yml config file is being picked up and read when any branch is commited to. The solution is to keep both projects strictly UI config based or config file based, in which case you'll need to use alternate yaml file naming or alternate yaml file location

  10. 10 Posted by oliver on 12 Jul, 2018 09:21 PM

    oliver's Avatar

    perfect.
    that fixed it.
    Thank you

  11. oliver closed this discussion on 12 Jul, 2018 09:21 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