tag:help.appveyor.com,2012-11-13:/discussions/problems/15074-restricting-project-to-one-branchAppVeyor: Discussion 2018-10-19T08:18:50Ztag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T06:53:07Z2018-07-12T06:53:07ZRestricting project to one branch<div><p>Hey</p>
<p>After this conversation: <a href="https://help.appveyor.com/discussions/questions/22261-branch-specific-version">https://help.appveyor.com/discussions/questions/22261-branch-specif...</a><br>
I decided to set up 2 AppVeyor projects for one github repository:<br>
* for master : <a href="https://ci.appveyor.com/project/AtlassianPS/atlassianps-configuration">https://ci.appveyor.com/project/AtlassianPS/atlassianps-configuration</a> * for all others: <a href="https://ci.appveyor.com/project/AtlassianPS/atlassianps-configuration-kbpew">https://ci.appveyor.com/project/AtlassianPS/atlassianps-configurati...</a></p>
<p>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:</p>
<p>However, this AppVeyor project is also triggered when I push a commit to <code>develop</code> branch.<br>
Can you help me?</p></div>olivertag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T15:55:24Z2018-07-12T15:55:24ZRestricting project to one branch<div><p>Could you try exporting yaml from your UI settings and checking that into the master branch?</p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T19:13:01Z2018-07-12T19:17:22ZRestricting project to one branch<div><p>Hi Owen.</p>
<p>I don't understand how that could work.<br>
I will not be able to maintain different yaml config files between the branches.<br>
Or is this merely for a test purpose?</p>
<p><strong>edit:</strong></p>
<p>I just tried it with this addition to the config:</p>
<pre>
<code> branches:
except:
- master</code>
</pre>
<p>the result is in the screenshot bellow</p></div>olivertag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T19:17:07Z2018-07-12T19:17:07ZRestricting project to one branch<div><p>uploading file vivaldi_2018-07-12_21-15-09.png</p></div>olivertag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T19:23:25Z2018-07-12T19:23:25ZRestricting project to one branch<div><p>full config:</p>
<pre>
<code> 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 "support@atlassianps.org"
- 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'))</code>
</pre></div>olivertag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T19:40:36Z2018-07-12T19:40:36ZRestricting project to one branch<div><p>Yes, just as a test.</p>
<p>I'm a little confused by your exported Yaml.<br>
This config setting seems to be working as it should.<br></p>
<pre>
<code>braches:
except:
- master</code>
</pre>
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 <strong>not</strong> 'All except branches specified below')?</div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T19:44:13Z2018-07-12T19:44:13ZRestricting project to one branch<div><p>I have 2 AppVeyor projects:<br>
1) AtlassianPS.Configuration --- which only takes branch <code>master</code><br>
2) AtlassianPS.Configuration@next --- which takes anything <strong>but</strong> branch <code>master</code></p>
<p>I exported for the 2) of these.<br>
Here a screenshot:</p></div>olivertag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T20:01:49Z2018-07-12T20:01:49ZRestricting project to one branch<div><p>Yes, this much i understood...<br>
But i'm trying to verify that the simple 'Export YAML' tab exported the exact same<br></p>
<pre>
<code>branches:
except:
- master</code>
</pre>
for two <strong>different</strong> 'Braches to build' settings in the 'General' tab.
<p>If you have 'Branches to build' setting 'Only branches specified below' to master this should yield<br></p>
<pre>
<code>branches:
only:
- master</code>
</pre></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T20:04:43Z2018-07-12T20:04:43ZRestricting project to one branch<div><p>Here both side by side:</p></div>olivertag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T21:04:34Z2018-07-12T21:04:34ZRestricting project to one branch<div><p>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.</p>
<p>Anyway, my colleague pointed me to <a href="https://stackoverflow.com/questions/45694142/appveyor-builds-for-all-branches-instead-of-specified-ones">this answer</a> he gave to someone with the same problem you're facing.</p>
<p>The summary is that the appveyor.yml config file is being picked up and read when <em>any</em> 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 <a href="https://www.appveyor.com/docs/build-configuration/#yaml-file-alternative-naming">alternate yaml file naming</a> or <a href="https://www.appveyor.com/docs/build-configuration/#alternative-yaml-file-location">alternate yaml file location</a></p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/456738822018-07-12T21:21:48Z2018-07-12T21:21:48ZRestricting project to one branch<div><p>perfect.<br>
that fixed it.<br>
Thank you</p></div>oliver