Azure-devops-docs: Run task if file/directory exists

Created on 26 Sep 2018  Â·  2Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

It would be really nice if we could create conditions based on the existence of a file/directory (even better a glob pattern).


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Most helpful comment

Interesting idea for a feature. You can simulate this using a script task that sets a variable.

- bash: |
    if [ -f your-file-here.txt ]; then
      echo "##vso[task.setVariable variable=FILEEXISTS]true"
    fi
- task: Foo@1
  condition: eq(variables.FILEEXISTS, 'true')

(From memory, not tested, etc.)

All 2 comments

Interesting idea for a feature. You can simulate this using a script task that sets a variable.

- bash: |
    if [ -f your-file-here.txt ]; then
      echo "##vso[task.setVariable variable=FILEEXISTS]true"
    fi
- task: Foo@1
  condition: eq(variables.FILEEXISTS, 'true')

(From memory, not tested, etc.)

Thanks for the feedback! That's pretty much the kind of workaround I'm using for this.

Was this page helpful?
0 / 5 - 0 ratings