tag:help.appveyor.com,2012-11-13:/discussions/problems/311-reset-the-build-number-automatically-ymlAppVeyor: Discussion 2019-06-27T05:24:11Ztag:help.appveyor.com,2012-11-13:Comment/330004852014-05-16T23:57:44Z2017-12-27T22:52:57ZReset the build number automatically (yml)<div><p>There is a better way setting build number as you want: <a href="https://www.appveyor.com/docs/build-worker-api/#update-build-details">https://www.appveyor.com/docs/build-worker-api/#update-build-details</a></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/330004852014-05-17T02:04:47Z2018-06-18T00:24:28ZReset the build number automatically (yml)<div><p>This seems to be a way of setting the whole version number myself, which I don't particularly want to do. I am happy with using the default 'increment by one' version numbers in these projects, at least for now, and simply changing the version header in the appveyor.yml when pushing updates hotfixes/versions/etc.</p>
<p>In my post, I am referring to this particular comment:</p>
<p><em>You can have "through" builds numbering in which major and minor parts of the version are changing and the build number is never reset or you can reset the build number for every new version.</em> -- <a href="http://www.appveyor.com/docs/build-configuration#build-versioning">http://www.appveyor.com/docs/build-configuration#build-versioning</a></p>
<p>It would seem to indicate that there is a way to choose this behavior, which would be perfect, however I can't find anything that would suggest any entries for appveyor.yml that would influence the build number generation.</p></div>JyeGurutag:help.appveyor.com,2012-11-13:Comment/330004852014-05-17T22:43:16Z2014-05-17T22:43:16ZReset the build number automatically (yml)<div><p>Oh, that phrase means you can reset build number on UI.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/330004852014-05-18T01:16:28Z2018-06-18T00:24:28ZReset the build number automatically (yml)<div><p>Ah, I see. In that case, is it possible request adding a 'reset build number to zero' option into the yml parser?</p></div>JyeGurutag:help.appveyor.com,2012-11-13:Comment/330004852014-05-18T02:12:03Z2014-05-18T02:12:03ZReset the build number automatically (yml)<div><p>Sure, what would be the trigger to reset build number to zero
then?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/330004852014-05-18T02:21:04Z2018-06-18T00:24:28ZReset the build number automatically (yml)<div><p>How about something simple like a new entry:</p>
<p><code>buildnumber: through|reset|force: #</code></p>
<p>This is presuming that it would respect the 'if not unique, then find lowest unique number' behavior that resetting it through the web interface would.</p>
<p><code>through</code> = current behavior <code>reset</code> = try {build}=1 and increment until unique version found <code>force: #</code> = try {build}=# and error if version not unique</p>
<p>Personally, I would just leave it on <code>reset</code> which would result in the numbering scheme in my first post (with the exception of {0} because I noticed after posting that {1} is the lowest value), however this should cover all use cases?</p></div>JyeGurutag:help.appveyor.com,2012-11-13:Comment/330004852014-05-18T18:58:58Z2014-05-18T18:58:58ZReset the build number automatically (yml)<div><p>Well, that's an interesting suggestion and I think it's pretty
doable. I'm going to add it to issues list. Thanks!</p>
<ul>
<li>Feodor</li>
</ul></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/330004852014-05-20T06:58:25Z2018-06-18T00:24:28ZReset the build number automatically (yml)<div><p>Thanks! :)</p></div>JyeGurutag:help.appveyor.com,2012-11-13:Comment/330004852015-08-19T14:46:23Z2015-08-19T14:46:23ZReset the build number automatically (yml)<div><p>I don't see the issue, what about this feature?</p></div>micdennytag:help.appveyor.com,2012-11-13:Comment/330004852016-02-19T00:25:51Z2016-02-19T00:35:47ZReset the build number automatically (yml)<div><p>Hello Feodor, can you tell us if this feature will be added? I'm
using the build number as my patch number for semantic versioning
and would love it if AppVeyor would be able to detec a new major or
minor version and reset the build number to 0. I think Yuki Hyou's
solution above would be perfect, except for reset, the
initially-tried value would be 0 and not 1.</p></div>Chris Simmonstag:help.appveyor.com,2012-11-13:Comment/330004852016-02-21T01:51:33Z2016-02-21T01:51:33ZReset the build number automatically (yml)<div><p>We've added a new REST API method to update next build number:
<a href="http://www.appveyor.com/docs/api/projects-builds#update-project-build-number">
http://www.appveyor.com/docs/api/projects-builds#update-project-bui...</a></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/330004852016-09-21T19:56:59Z2016-09-21T19:57:00ZReset the build number automatically (yml)<div><p>Is it possible right now to auto reset the build number? a rest
api call is not automatically integrateable in open source
projects.</p>
<p>My request:<br>
If I increase Major or Minor the Build number should be reset
automatically to 0.<br>
Optional property of yml like Yuki Hyou here said in 2014.</p></div>Benjamin Abttag:help.appveyor.com,2012-11-13:Comment/330004852017-06-19T09:38:27Z2017-08-10T16:49:36ZReset the build number automatically (yml)<div><p>I would also like this feature to be available through YAML config</p></div>bazzilictag:help.appveyor.com,2012-11-13:Comment/330004852017-07-07T20:36:40Z2017-07-07T20:36:43ZReset the build number automatically (yml)<div><p>The optional property in the yml would be useful to me too. We already manipulate the yml when doing releases to force the major/minor version number, but doing an API call means we need to code an extra step somewhere in our pipeline.</p>
<p>For future generations though ...</p></div>Daniel Wilchestag:help.appveyor.com,2012-11-13:Comment/330004852017-12-27T21:55:31Z2017-12-27T21:55:31ZReset the build number automatically (yml)<div><p>+1 for me.</p>
<p>Although this would work perfectly for many:</p>
<p>appveyor.yml:<br>
buildnumber:<br>
#reset build number on a tag build resetOnTag: 0</p></div>ericnewton76tag:help.appveyor.com,2012-11-13:Comment/330004852017-12-27T21:58:44Z2017-12-27T21:58:44ZReset the build number automatically (yml)<div><p>Could this be added to the Powershell cmdlets?</p>
<p>sample appveyor yml:<br>
on_init:<br>
- ps: if($env.APPVEYOR_REPO_TAG -eq "true") { Set-BuildNumber 0 }</p></div>ericnewton76tag:help.appveyor.com,2012-11-13:Comment/330004852018-03-22T16:37:19Z2018-03-22T16:37:20ZReset the build number automatically (yml)<div><p>Any updates on this?</p></div>niveus_evertotag:help.appveyor.com,2012-11-13:Comment/330004852018-06-17T16:04:05Z2018-06-18T09:43:57ZReset the build number automatically (yml)<div><p>@niveus_everto</p>
<p>Hey, I reset the build number of one of my projects in order to have -preview1, -preview2 and so on<br>
on the next non-tagged builds, until the next tagged build.</p>
<p>I think you can adapt it for your needs:</p>
<pre>
<code>environment:
APPVEYOR_TOKEN:
secure: XxxxxxxxxxxxxxxxxxXXxxxxxxxxxxxxxxxx=
after_deploy:
- ps: script-below.ps1</code>
</pre>
<p>Power shell script:</p>
<pre>
<code>if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
$headers = @{
"Authorization" = "Bearer $env:APPVEYOR_TOKEN"
"Content-type" = "application/json"
"Accept" = "application/json"
}
$build = @{
nextBuildNumber = 1
}
$json = $build | ConvertTo-Json
Invoke-RestMethod -Method Put "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/build-number" -Body $json -Headers $headers
}</code>
</pre>
<p>P.S. Please note APPVEYOR_TOKEN variable contains <a href="https://ci.appveyor.com/tools/encrypt">an encrypted</a> API token. You can find your AppVeyor API key <a href="https://ci.appveyor.com/api-token">here</a></p></div>salaros