Reset buildcounter and change a property in a dependency


We have two builds:
- daily, version format is
- Release, version format is 1.0.%build.number%.0

Release depends on Daily.

We would like to be able to:
1) Reset buildcounter of a Daily build when Release build starts
2) Update property of a Daily build when Release build starts

I tried putting a PowerShell script to use REST API to do this:

$user = "%system.teamcity.auth.userId%"
$pass= "%system.teamcity.auth.password%"

$secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)

Invoke-RestMethod -Uri %teamcity.serverUrl%/httpAuth/app/rest/buildTypes/id:90/parameters/ -Method PUT -Credential $cred -Body %build.counter%
Invoke-RestMethod -Uri %teamcity.serverUrl%/httpAuth/app/rest/buildTypes/id:90/settings/buildNumberCounter -Method PUT -Credential $cred  -Body 0

But I am getting a 403 error, because that user doe not have permissions to change build configurations.

Please advice how can I achieve my task.

1 comment
Comment actions Permalink

It seems like you are trying to achieve the same as me in except that you seem to use a Powershell script and the REST API for TeamCity, I would much rather use some type of code where I could write this as a plugin for a Build runner :)


Please sign in to leave a comment.