Search code examples
teamcityteamcity-rest-api

Add build artifact to TeamCity asynchronously


I have a build config which simply runs a powershell script and below is what this script does

  • Call first rest API method which starts a long running job
  • Call second rest API method which checks status of the job (periodically, until status is completed)
  • Finally, call third rest API method which downloads a html report file (the artifact)

Everything works fine and after all I show the report in a report tab. Note that, rest api methods belong to some other system, they are not TeamCity's rest api methods.

The problem is, this script locks the build agent until long running job finishes executing. What I am looking for is a TeamCity end point such that it can add an artifact to a completed build. Other system is able to POST report file to a rest endpoint. I checked Build Artifacts section of TeamCity Rest API guide but it seems like there are only a few GET methods, what I need is a POST method.

Can anyone suggest another solution or clearify me if TeamCity already has this feature?


Solution

  • Currently it's not supported. The related request in TeamCity issue tracker: https://youtrack.jetbrains.com/issue/TW-11277. The current workaround id to put files manually into <TC_DATA_DIR>/system/artifacts/PROJECT_ID/BUILD_CONFIGURATION_ID/INTERNAL_BUILD_ID directory.