使用PowerShell触发具有工件依赖性的Teamcity作业

时间:2019-06-24 07:37:49

标签: teamcity powershell-4.0

我正在尝试使用PowerShell执行teamcity作业。如果我仅使用buildtype id运行作业,则工作正常,但我需要根据工件依赖项id执行。有人可以帮助我配置正确的xml结构吗?

我正在使用Teamcity 2018.1.5 o Windows 10平台在PowerShell版本5.1中进行尝试

$user = "abc"
$password = "password"
$teamCityHost = "http://127.0.0.1:80"
$pair = "$($user):$($password)"

$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$headers = @{
    "Authorization" = $basicAuthValue;
    "Accept" = "application/xml";
    "Content-Type" = "application/xml";
}

$buildId = "Optimist8Trunk_TestPowershellAutomation"
$body = "<build><buildType id=""$buildId""/></build>"
$api = "$($teamCityHost)/httpAuth/app/rest/buildQueue"

$response = Invoke-WebRequest -Uri $api -Headers $headers -Method POST -Body $body

我希望$ body变量也应该包含工件依赖项,并且不仅包含buildtype id。我应该选择基于旧的工件依赖项ID来触发作业,而不仅仅是使用最新版本。

0 个答案:

没有答案
相关问题