tag:help.appveyor.com,2012-11-13:/discussions/problems/17303-branch-in-version-is-always-master-for-merge-requestsAppVeyor: Discussion 2018-10-08T19:37:21Ztag:help.appveyor.com,2012-11-13:Comment/462043332018-10-06T01:41:23Z2018-10-06T01:41:23Z{branch} in version is always "master" for merge requests<div><p>We have a whole bunch of PR-related variables:</p>
<pre>
<code>APPVEYOR_PULL_REQUEST_NUMBER
APPVEYOR_PULL_REQUEST_TITLE
APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME
APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
APPVEYOR_PULL_REQUEST_HEAD_COMMIT</code>
</pre>
<p>They are documented <a href="https://www.appveyor.com/docs/environment-variables/">here</a>, we need to remove <code>GitHub only</code> part from doc.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/462043332018-10-06T11:50:02Z2018-10-06T11:50:02Z{branch} in version is always "master" for merge requests<div><p>Oh, so I can use general environment variables in "version" field for a build now?</p>
<p>Past support material I found suggested only two special variables ({branch} and {build}) were allowed here.</p></div>eduard.braun2tag:help.appveyor.com,2012-11-13:Comment/462043332018-10-08T19:37:19Z2018-10-08T19:37:19Z{branch} in version is always "master" for merge requests<div><p>Yes, those are special "shortcut" variables. But you can add other variables with standard variable syntax, e.g. <code>$(APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH)</code>.</p>
<p>However I believe that in your case you need to conditionally use main branch for push builds and head branch for MR builds. For that you can <a href="https://www.appveyor.com/docs/build-worker-api/#update-build-details">update build from command line</a> and use <code>APPVEYOR_REPO_BRANCH</code> for push builds (simple condition is that <code>APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH</code> is empty string).</p>
<p>By the way I feel good proposing this now as side effects described <a href="https://github.com/appveyor/ci/issues/1074">here</a> will not happen no more :)</p></div>Ilya Finkelshteyn