I'm trying to queue a new build from PowerShell using the TFS Rest API. I'm able to queue a new build but I would like to set the requestedBy property. In the docs one can read that you can pass additional parameters. I can't find any further documentation on what these parameters can be. Does anyone know if this can be done?
Using the tfsbuild.exe
(to queue XAML builds) you can pass an additional argument like this:
&$tfsBuild.Exe start "url" project definition /requestedFor:"$buildRequestedFor" /queue
edit
I've been able to get this working. The body of the request looks like:
$json = "{
""definition"": {
""id"" : 174
}
,""requestedFor"": {
""id"": ""6f4d7323-fa51-4cda-9eb4-7342b02ba087""
}
}" `
You can only use the id propery. Using uniqueName for example will fail.
Here's the full PowerShell code:
$user = ""
$pass= ""
$uri = "http://Instance/DefaultCollection/Project/_apis/build/builds?api-version=2.0"
$json = "{
""definition"": {
""id"" : 174
}
,""requestedFor"": {
""id"": ""6f4d7323-fa51-4cda-9eb4-7342b02ba087""
}
}"
$secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)
Invoke-RestMethod -Uri $uri -Method Post -Credential $cred -ContentType "application/json" -Body $json