REST API: can I query for last build with a particular artifact?

i would like to find the latest build on a particular branch that has an artifact called
coverage.xml

Is this possible?

2 comments

Hi Marc,

No, it's not possible. You can create a build script, that:

  1. requests the list of builds on particular branch
  2. iterates over the list of returned builds and requests the list of artifacts for each one:

          GET http://teamcity:8111/httpAuth/app/rest/builds/

<build_locator>
/artifacts/content/
<path>

        Stops and returns the build locator if coverage.xml is found.

Why do you need to find such builds using REST API?
0

Hi again,

The second approch is available. Since TeamCity 9.1.x you can use the following request:

http://domain/app/rest/builds?locator=buildType:(id:<buildConfiguration_id>)&fields=build(id,artifacts(file(name),$locator(recursive:true,pattern:<path_to_build_artifact>)))

This request returns the list of all builds, but builds that contain requested artifact have the following pattern:

<artifacts>
     <file name="<build_artifact>"/>
</artifacts>
0

Please sign in to leave a comment.