TeamCity REST API:使用自定义工件依赖性触发构建

时间:2015-05-08 16:28:59

标签: teamcity

我正在尝试使用TeamCity 8.1 REST API触发自定义构建(请参阅https://confluence.jetbrains.com/display/TCD8/REST+API#RESTAPI-TriggeringaBuild)。我的构建运行良好,我能够指定自定义分支和属性没有问题。我的目标是为我正在触发的构建指定一个自定义工件依赖项。

创建构建时收到的响应如下所示:

<?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>

此响应中的“custom-artifact-dependencies”标记让我相信有一种方法可以指定自定义依赖项,但我在TeamCity文档,TeamCity论坛或Google中没有找到任何解释可以完成。有什么我在这里可以忽略的或其他方式来实现这个目标吗?

将以下内容添加到“build”标记的子代中会导致“Artifact依赖项应该具有类型'artifact_dependency'。”错误:

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

服务器可能会将我的意图与构建配置API混淆,以设置和查看工件依赖项(例如http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/artifact-dependencies/

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题 这对我有用:

    <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>

如果'parentBuildConfig'构建仍在运行,请将buildId参数替换为taskId

相关问题