0

I have an array in bash that looks like:

libs=test1 test2

I would like to use the output of the bash script in a subsequent step in an ADO pipeline. How can I loop over this in ADO with pipeline variables like:

- ${{ each value in $(libs) }}:
   - script: echo $value
   - task: Npm@1
     inputs:
      command: 'custom'
      customCommand: npm publish --ignore-scripts
      workingDir: 'dist/libs/$(value)'
      publishRegistry: 'useFeed'
      publishFeed: 'feed'
2
  • 1
    libs=test1 test2 is not an array; libs=test1 assigns the string test1 to the variable libs while test2 is treated as a command and, unless you have a command/alias/function named test2, should generate an error; libs=(test1 test2) , or libs=('test1' 'test2'), creates an array named libs Commented Feb 13, 2022 at 17:17
  • Thanks for correcting. I would like to use the libs variable array (test1 test2) to loop over in ADO pipeline, as mentioned above. Any ideas? Commented Feb 14, 2022 at 9:17

1 Answer 1

1

Unfortunately, you cannot as each statement works only with parameters and not variables (as per documentation).

Moreover, variables are only string while parameters have different data type.

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.