I'm, trying to create a TeamCity build that receives two parameters: the first will be a list of values delimited by commas (or any other character) and the second will be a single value. The job should then split the first list and call a second job once for each of the values in the first list.
Example:
Job1 "value1,value2,value3", "other_value"
Should queue three new builds:
Job2 "value1", "other_value"
Job2 "value2", "other_value"
Job2 "value3", "other_value"
Job2 is already defined in the server and I wouldn't want to change it. For Job1 this is what I got so far:
Param([string]$teamcity_url, [string]$user, [string]$pass, [string]$values, [string]$other_value)
$envs = $values.Split(',');
foreach ($env in $envs) {
$req = $teamcity_url + "/httpAuth/action.html?add2Queue=<id>&name=env&value=" + $env + "&name=other&value=" + $other_value
$web = New-Object System.Net.WebClient
$web.Credentials = New-Object System.Net.NetworkCredential($user, $pass)
$web.DownloadString($req)
}
I would like to pass as $user and $pass the same username and password as the one for the user who triggered Job1. I know how to get the username: teamcity.build.triggeredBy.username, but I don't know how or if I can get the password. I understand the security concerns.
In the absence of this, what other option could I use to accomplish the same?