Our TeamCity project has components for triggered build and unit tests on commits, nightly functional tests, and manual deployment. Currently, the deployment job can be run even when the functional tests have failed. To prevent this, I'd like to enable a pre-condition whereby a deployment can't be run or will fail if the nightly functional tests have failed.

I'm not sure if this should be done with a build step or a dependency. There aren't actual snapshot or artifact dependencies involved, just a job status.


1 Answers


I found a way to do this in a Powershell build step with the TeamCity REST API and guest authentication.

$url = "nytc:7070/guestAuth/app/rest/buildTypes/id:CharlesRiver_MainFunctionalTest/builds/canceled:false/status"
if ($url -ne "SUCCESS")
  "Can't run deploy if tests have failed."
  "##teamcity[buildStatus status='FAILURE' text='Deploy cannot run because function tests have failed']"
  exit 1