0

Is it possible to tag TeamCity builds using service messages or some other programmatic way from a build step maybe...?

How can this be done?

carlspring
  • 31,231
  • 29
  • 115
  • 197

3 Answers3

1

There is a VCS labelling in TeamCity, you can tag when a build successful, or on each build. Does it correspond to what you're looking for?

Gerald
  • 690
  • 4
  • 13
  • VCS labeling is configured on the Build Features page of the Build Configuration settings. You can add a build features, and you choose how you want to label your sources. This works with TeamCity 8.1. Priro to that version, it's in VCS Settings of the Build Confiuration Settings – Gerald Nov 22 '14 at 20:25
  • You are basically describing labelling on the VCS level, not the level of the build server. TeamCity has tagging features of its own, which is slightly confusing when talking of tags in VCS at the same time. – oligofren Jan 14 '20 at 15:20
1

See also the following stackoverflow discussion:

Programatically pin a build in Teamcity

Moreover, since there were two open questions on stackoverflow and I had the same problem, I wrote a TeamCity plugin that solves it:

https://github.com/echocat/teamcity-buildTagsViaBuildLog-plugin

Community
  • 1
  • 1
Tobel
  • 66
  • 4
1

Yes, there is. You can use the REST API, as described here. Basically,

Adding a tag using plain text

curl -s  --header "Authorization: Bearer $TOKEN" \
    -H 'Content-Type: text/plain' \
    "https://ci.ACME.com/app/rest/builds/5375/tags --data tag-1 
tag-1

Reading the list of tags as json

curl -s -H 'Accept: application/json'  \
     -H "Authorization: Bearer $TOKEN" \
     "https://ci.ACME.com/app/rest/builds/5375/tags"
{"count":1,"tag":[{"name":"tag-1"}]}

Overwriting tags using json, getting it back as xml (the default)

curl -s  --header "Authorization: Bearer $TOKEN" \
     -H 'Content-Type: application/json' -X PUT \
    "https://ci.ACME.com/app/rest/builds/5375/tags \
     --data '{"count":2,"tag":[{"name":"tag-A"},{"name":"tag-B"}]}'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><tags count="2"><tag name="tag-A"/><tag name="tag-B"/></tags>
oligofren
  • 20,744
  • 16
  • 93
  • 180