Last active
October 31, 2021 23:31
-
-
Save yetanotherchris/d83391afba959b27dbcd to your computer and use it in GitHub Desktop.
Trigger another Teamcity build as a build step (because Teamcity triggers lose the triggeredBy environmental variable)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Trigger the acceptance tests | |
# Docs: https://confluence.jetbrains.com/display/TCD8/REST+API#RESTAPI-TriggeringaBuild | |
$branchName = "%teamcity.build.branch%" | |
$url = "http://teamcity.mydomain.com:8500/guestAuth/app/rest/buildQueue" | |
$buildId = "%system.teamcity.buildType.id%" | |
$buildId = $buildId.Replace("_Deploy", "_AcceptanceTests") | |
$webClient = New-Object net.webclient | |
try { | |
$xml = "<build branchName=`"$branchName`"><buildType id=`"$buildId`"/></build>" | |
Write-host "Sending this xml to $url : $xml" | |
$webClient.Headers.Add("Content-Type", "application/xml") | |
$webClient.UploadString($url, $xml) | write-host "ok" | |
} | |
catch { | |
Write-Host "Looks like this project doesn't have acceptance tests, ignoring." | |
exit 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment