REST API: Problem with getting build artifact information

I'm using the shell script below inside a TC build configuration to (try to) retrieve the artifacts information of another build using the REST API.

  build=$(curl -q -X GET -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" \
      https://TEAMCITY/app/rest/builds/id:$id/artifacts/children | tr '\n' ' ')
count="$(echo $build | jq -r '.count')"
iter=0
while [ $count -eq 0 ] && [ $iter -lt 10 ];
  do
    sleep 60
    iter=$((iter + 1))
    build=$(curl -q -X GET -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" \
      https://TEAMCITY/app/rest/builds/id:$id/artifacts/children)
    count="$(echo $build | jq -r '.count')"
done

I've checked - also via the REST API - that the build has completed before the above code runs. I've tried waiting even 30minutes after the build finishes, but no joy. I keep getting

{"count":0,"file":[]}

I am getting the artifacts of a different build within the same shell script and that always works.

A long time later, I just tried it from the command-line for the same build ID which failed, and I get the correct response.

0
1 comment

Hello,

Does this issue reproduce with other builds also or just one? Are the missing artifacts visible in the UI? Are you using artifact dependencies or any triggers to run the build that has this script?

Thank you,

Guilherme

0

Please sign in to leave a comment.