0
votes

So I defined a process template that accepts a String array called BuildDefinitionList in my Build Definition. I then call a powershell script. What I want to do is retrieve the array of type String. How do I achieve this from my powershell script?

Update:

I've modified the process template to have a InvokeProcess activity with a script path argument and a script arguments argument. In order to customize my definition, I've used the following as a guidance here.

I have a process parameter called Script which has the path to the powershell script I have another process parameter called ScriptArguments which has the following.

builds `"Test 1`", `"Test 2`", `"Test 3`", `"Test 4`"

My script accepts or is looking for a String array

[cmdletbinding()]
Param(
    [Parameter(Mandatory=$false,
                       ValueFromPipeline=$true,          
             ValueFromPipelineByPropertyName=$true)]
    $builds
)

When I run my build, I get the following error

A positional parameter cannot be found that accepts
 argument 'Test 1'.
1

1 Answers

-1
votes

You create a parameter, and specify the type of [String[]] for it.

Param(
[String[]]$SomeStrings
)
ForEach($String in $SomeStrings){
    Do stuff!
}

Then just pass the array to the script when you call it.