tag:help.appveyor.com,2012-11-13:/discussions/problems/2874-how-can-i-add-commit-id-to-build-versionAppVeyor: Discussion 2018-10-19T08:17:25Ztag:help.appveyor.com,2012-11-13:Comment/377339352015-08-23T15:59:35Z2015-08-23T16:11:46ZHow can I add commit ID to build version?<div><p>I want to add commit ID to my build version.<br>
I changed the first line of appveyor.yml like below.<br>
version: 0.0.1_%APPVEYOR_REPO_COMMIT%</p>
<p>Now a project is being built and the CONSOLE is showing
nothing.<br>
I think something maybe hang due to the wrong format of
version.<br>
I want to cancel this build but it doesn't response to me.</p>
<p>So what is the correct format of version to add commit id?<br>
And please help me to cancel the build!!!</p>
<p>Update: now this build is stopped after running nearly 40
minutes.</p></div>lsmgeb89tag:help.appveyor.com,2012-11-13:Comment/377339352015-08-23T16:37:26Z2015-08-23T16:37:26ZHow can I add commit ID to build version?<div><p>It won't be expanded like that. There could only two variables
within version format: <code>{build}</code> and
<code>{branch}</code>.</p>
<p>If you want to add commit id to a build version you can do that
using <a href="http://www.appveyor.com/docs/build-worker-api#update-build-details">
this API</a>. With a little PS script like that:</p>
<pre>
<code>init:
- ps: Update-AppveyorBuild -Version "0.0.$env:appveyor_build_number-$($env:appveyor_repo_commit.substring(0,7))"</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/377339352015-08-23T16:55:05Z2015-08-23T16:55:05ZHow can I add commit ID to build version?<div><p>Thank you for your solution and quick reply.<br>
Another question:<br>
Can I delete a failure build record in the project history?</p></div>lsmgeb89tag:help.appveyor.com,2012-11-13:Comment/377339352015-08-23T16:56:22Z2015-08-23T16:56:22ZHow can I add commit ID to build version?<div><p>Nope, it can't be deleted.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/377339352015-08-23T17:06:02Z2015-08-23T17:06:02ZHow can I add commit ID to build version?<div><p>OK, thx, I want to return something related to my first
question.<br>
How can I refer updated build version in the cmdlet or powershell
after adding init script in the init part?<br>
I use %APPVEYOR_BUILD_VERSION% in the cmd, but it remains the old
version number.</p></div>lsmgeb89tag:help.appveyor.com,2012-11-13:Comment/377339352015-08-23T17:42:19Z2015-08-23T17:42:19ZHow can I add commit ID to build version?<div><p>It depends on how/when you change build version.</p>
<p>I've just tested here and it worked:<br>
<a href="https://github.com/FeodorFitsner/nuget-test/blob/master/appveyor.yml#L3-L7">
https://github.com/FeodorFitsner/nuget-test/blob/master/appveyor.ym...</a></p>
<p>Build results:<br>
<a href="https://ci.appveyor.com/project/FeodorFitsner/nuget-test/build/0.0.226-3a34c45#L6">
https://ci.appveyor.com/project/FeodorFitsner/nuget-test/build/0.0....</a></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/377339352015-08-24T03:01:02Z2015-08-24T03:01:17ZHow can I add commit ID to build version?<div><p>After checking my yml file, I have found my problem.<br>
I restart machine after changing build version.<br>
So Changing it after restarting machine solved the problem.</p>
<p>Thank you for your all great help.</p></div>lsmgeb89