Last active
January 13, 2021 13:52
-
-
Save software-programmer/a75a98dfff1a08d670b6d1fd402e51a5 to your computer and use it in GitHub Desktop.
This script can be used inside TeamCity to get the build status of a build configuration and write the value back out to a parameter. http://evsoftware.co.uk
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
# Set Build Configuration Id | |
$BuildTypeId = "BuildConfiguration_Name" | |
# Create Credentials using built in user / password | |
$ApiCredentials = New-Object System.Management.Automation.PSCredential("%system.teamcity.auth.userId%", (ConvertTo-SecureString "%system.teamcity.auth.password%" -AsPlainText -Force)) | |
# Invoke and get status | |
$status = Invoke-RestMethod -Credential $ApiCredentials -Uri "%teamcity.serverUrl%/httpAuth/app/rest/builds/buildType:$BuildTypeId/status" -Method GET; | |
# Set to an output parameter | |
Write-Host "##teamcity[setParameter name='BuildConfiguration_Name_Status' value='$status']" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment