Skip to content

Instantly share code, notes, and snippets.

@TomerAdmon
Created December 28, 2016 16:51
Show Gist options
  • Save TomerAdmon/ebe3842d796887d9112d0ee8a5543e16 to your computer and use it in GitHub Desktop.
Save TomerAdmon/ebe3842d796887d9112d0ee8a5543e16 to your computer and use it in GitHub Desktop.
Update all build configuration in TeamCity to checkout on agent
$TEAMCITY_URL = "http://tc"
##$secpasswd = ConvertTo-SecureString “PASSWORD” -AsPlainText -Force
##$mycreds = New-Object System.Management.Automation.PSCredential (“USERNAME”, $secpasswd)
$mycreds = Get-Credential
$builds = [xml](Invoke-RestMethod -Method Get ($TEAMCITY_URL + "/httpAuth/app/rest/buildTypes") -Credential $mycreds)
foreach ($build in $builds.buildTypes.buildType)
{
$buildUri = $TEAMCITY_URL + "/httpAuth/app/rest/buildTypes/id:" + $build.id + "/settings/checkoutMode"
$response = Invoke-RestMethod -Method Get -Uri $buildUri -Credential $mycreds
if ($response -match "ON_SERVER")
{
write-host $build.href
$response = Invoke-RestMethod -Method Put -Uri $buildUri -Credential $mycreds -Body "ON_AGENT"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment