dman
dman

Reputation: 11064

Azure Devops Bash says wrong file path but script 'ls' shows it to be correct

Azure DevOps - I am getting ##[error]Invalid file path '/home/vsts/work/1/s/docker-e2e'. for my bash script in the bash task.

However, - script: ls '$(System.DefaultWorkingDirectory)/docker-e2e' shows correctly:

2021-06-21T17:03:29.2609773Z ls '/home/vsts/work/1/s/docker-e2e'
2021-06-21T17:03:29.2610385Z ========================== Starting Command Output ===========================
2021-06-21T17:03:29.2629573Z [command]/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/f4f42ebe-2929-4239-8697-1e61770cf4df.sh
2021-06-21T17:03:29.2680715Z docker-compose-e2e.yml
2021-06-21T17:03:29.2682129Z wait-for-widgets-online.sh
2021-06-21T17:03:29.2891004Z ##[section]Finishing: CmdLine

What I am doing wrong?

stages:
  - stage: e2e
    displayName: run e2e tests
    pool:
      vmImage: "ubuntu-20.04"
    jobs:
      - job: runE2E
        displayName: Run E2E
        steps:
          - script: ls $(System.DefaultWorkingDirectory)/docker-e2e
          - task: Bash@3                                        
            inputs:                                             
              filePath: $(System.DefaultWorkingDirectory)/docker-e2e
              script: wait-for-widgets-online.sh         

Upvotes: 2

Views: 4259

Answers (1)

qbik
qbik

Reputation: 5928

You can pass the script content to Bash task either by filePath (which should be a path to a file, not a directory) or by script (which should be the content of the script, not a path).

In your case, it should simply be:

- task: Bash@3                                        
  inputs:                                             
    filePath: $(System.DefaultWorkingDirectory)/docker-e2e/wait-for-widgets-online.sh

Upvotes: 1

Related Questions