Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Teamcity 使用参数触发构建_Teamcity - Fatal编程技术网

Teamcity 使用参数触发构建

Teamcity 使用参数触发构建,teamcity,Teamcity,在TC升级至2018年之后 我以前使用参数触发TC构建的脚本不起作用 我们使用的脚本使用以下api: https://[server]/httpAuth/action.html?add2Queue=[build name]&name=[param name]&value=[param value] 我正在尝试迁移到restApi from(): 我试过了 https://[server]/app/rest/buildQueue?locator=buildType:[build name],[pa

在TC升级至2018年之后 我以前使用参数触发TC构建的脚本不起作用

我们使用的脚本使用以下api:

https://[server]/httpAuth/action.html?add2Queue=[build name]&name=[param name]&value=[param value]

我正在尝试迁移到restApi from():

我试过了

https://[server]/app/rest/buildQueue?locator=buildType:[build name],[param name]:[param value]

目前我有两个问题:

  • 我成功触发了一个构建-但尚未触发
  • 文档不清楚,如何使用参数触发构建? 您能否建议如何使用参数成功触发构建(也可以超过1个)

  • 首先,您对TeamCity的文档不清楚。对此,

    若要触发生成,必须对此url发出POST请求,并通过正文发送buildType id

    http://localhost:8111/httpAuth/app/rest/buildQueue 
    
    您还可以将配置参数传递到主体中

    带参数的触发器生成的XML正文:

    <build><buildType id="YourBuildTypeId"/>
    <properties><property name="PARAM1" value="VALUE1"/></properties>
    </build>
    
    {
      "buildType": {
      "id": "YourBuildTypeId"
    },
      "properties": {
      "property": [
        {
         "name": "PARAM1",
         "value": "VALUE1"
        },
        {
         "name": "PARAM2",
         "value": "VALUE2"
        }
       ]
      }
    }
    
    您可以使用下面的curl脚本

    curl -X POST \
    http://localhost:8111/httpAuth/app/rest/buildQueue \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/xml' \
    -d '<build><buildType id="YourBuildTypeId"/>
    <properties><property name="PARAM1" value="VALUE1"/></properties>
    </build>'
    
    curl-X POST\
    http://localhost:8111/httpAuth/app/rest/buildQueue \
    -H'Accept:application/json'\
    -H'内容类型:应用程序/xml'\
    -d'
    '
    
    升级到TC 2018后,我们的脚本在上面的GET调用中开始失败。将其更改为POST call解决了该问题。无需迁移到新的TC REST API,因为它仍然向后兼容。