Is it possible to tag TeamCity builds using service messages (or some other programatic way)?

1.1k views Asked by At

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?

3

There are 3 answers

0
Tobel On BEST ANSWER

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

2
Gerald On

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?

0
oligofren On

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>