1
votes

I'm trying to trigger a custom build using the TeamCity 8.1 REST API (see https://confluence.jetbrains.com/display/TCD8/REST+API#RESTAPI-TriggeringaBuild). My builds run fine and I'm able to specify custom branches and properties with no issue. My goal is now to specify a custom artifact dependency for the builds I'm triggering.

The response I receive when creating a build is something like the following:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
  <build taskId="1234" buildTypeId="buildConfig1" state="queued" ...>
  <buildType id="buildConfig1" name="Build Config Name"  ... />
  ...
  <properties count="1">
    <property name="testParam" value="Test 123" own="true" />
  </properties>
  <custom-artifact-dependencies />
</build>

The "custom-artifact-dependencies" tag in this response leads me to believe that there is a way to specify custom dependencies, but I have not found anything in the TeamCity documentation, the TeamCity forums, or from Google explaining how this can be accomplished. Is there something I'm overlooking here or another way of accomplishing this?


Adding the following to as a child of the "build" tag results in an "Artifact dependency should have type 'artifact_dependency'." error:

<custom-artifact-dependencies>
 <artifact-dependency buildId="5432" buildTypeId="parentBuildConfig"/>
</custom-artifact-dependencies>

The server may be confusing my intention with the build configuration API for setting and viewing artifact dependencies (e.g. http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/artifact-dependencies/)

1

1 Answers

4
votes

I had the same problem This is what worked for me:

    <build>
      <triggeringOptions queueAtTop="true"/>
      <buildType id="buildConfig1"/>
      <custom-artifact-dependencies count="1">
       <artifact-dependency id="0" type="artifact_dependency">
        <properties>
         <property name="pathRules" value="Artifacts_1.zip
Artifacts_2.zip
Artifacts_To_Unzip.zip!/**
"/>
         <property name="cleanDestinationDirectory" value="true"/>
         <property name="revisionName" value="buildId"/>
         <property name="revisionValue" value="5432"/>
        </properties>
        <source-buildType id="parentBuildConfig" />
       </artifact-dependency>
      </custom-artifact-dependencies>
    </build>

If the 'parentBuildConfig' build is still running, replace the buildId parameter with taskId