azureazure-devopsazure-pipelinesazure-aksazure-pipelines-yaml

While scanning a simple key, could not find expected ':'. Syntax error in azure-pipeline.yaml


I am trying to execute an azure pipeline. It was executing fine. But when I added a task to conditionally check pom.xml file exists then only I need to execute that particular task, but it fails

enter image description here

Error

enter image description here


Solution

  • Your script needs to be more indented:

    - bash: |
        if [ -f Maven pom.xml ]; then
          echo "##vso[task.setVariable variable=FILEEXISTS]true"
        fi
    - task: Maven@3
        etc
    

    See an example here: https://stackoverflow.com/a/58555822/174843