1

Actually I'm trying to repeat a task on Azure DevOps Pipeline a set of objects that are defined in paramaters field as below:

parameters:
- name: container-names
  displayName: a list of choices
  type: object
  default:
    - appName1
    - appName2
    - appName3
    - appName4

Now what I would like to do is to provide the name of these apps in an ansible@0 as follow:

  - stage: TST
    displayName: 'Deploy TST'

    jobs:
      - job: download_and_execute_playbook
        pool:
          name: 'CDaaSLinux'

        steps:

          ...
          ...
          ...

        - ${{ each container in parameters.container-names }}:          
          - task: Ansible@0
            inputs:
              ansibleInterface: 'agentMachine'
              playbookPathOnAgentMachine: '$(System.DefaultWorkingDirectory)/ansible/site_main.yaml --limit test -vvv --extra-vars "service=${{ container }}"'
              inventoriesAgentMachine: 'file'
              inventoryFileOnAgentMachine: '$(System.DefaultWorkingDirectory)/ansible/hosts.yaml'

It looks like it can be achieved regarding the documentation but I get this error message when trying to implement it:

enter image description here

/pipelines/stop-start.yaml (Line: 118, Col: 13) Unexpected symbol 'container-names'. Located at position 12 within expression: parameter.container-names

Any help would be appreciated

0

1 Answer 1

3

You need to use a different syntax if your parameter or variable name contains special characters like - or .: parameters['container-names'].

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

1 Comment

Absolutely ! It worked :) Thanks @Daniel

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.