0

I'm trying to figure out if there is a way to pass arguments to a next line script from PowerShell array.

Ex:

$array = @('a','b','c') # This can keep increasing. 

cobertura-merge -o coverage/cobertura-coverage.xml $array[0] $array[1] $array[2]

Can someone please let me know, how to accomplish this if there are n no.of elements in the array?

Raag!

0

1 Answer 1

0

You can't store actually a complex value in variable. So you have to first join and then split it

- pwsh: |
    $val = @('a','b','c') -join ";"
    Write-Host "##vso[task.setvariable variable=paramaeters;]$val"

- pwsh: | 
    $paramaeters = '$(paramaeters)'.split(";")

    cobertura-merge -o coverage/cobertura-coverage.xml @paramaeters

Passing array should be fine as it is shown here

Please be awate that it will work if you do both steps inside the same job. Otherwise you need yo use output variables.

Please change $parameter to @parameters to use splatting arrays

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.