aws / aws-toolkit-azure-devops

AWS Toolkit for Azure DevOps
Other
249 stars 106 forks source link

AWSShellScript@1 can't locate the file in workingDirectory #488

Open sreeprasadn opened 2 years ago

sreeprasadn commented 2 years ago

Describe the bug

To reproduce

  1. Azure Pipeline step include two tasks. Script lists the files in workingDirectory and then AWSShellScript to run the script from workingDirectory

    steps:
    - checkout: GunslingerRepo
    - checkout: self
    
    - script: |
      ls
    displayName: Validate variable 
    workingDirectory: '$(System.DefaultWorkingDirectory)/temp/'
    
    - task: AWSShellScript@1
    displayName: 'Functional Test'
    inputs:
      awsCredentials: 'terraform-azuredevops-development'
      regionName: 'eu-central-1'
      scriptType: 'filePath'
      arguments: '${{parameters.branch}} ${{parameters.validation}} ${{parameters.dataflow}} ${{parameters.iterations}} $(case1) $(case2) $(case3) $(case4)'
      filePath: ./functional-test.sh
      workingDirectory: '$(System.DefaultWorkingDirectory)/temp/'

Expected behavior

Expected the file function-test.sh in workingDirectory to be found and executed successfully.

Screenshots

The first task lists the files in the workingDirectory: image

AWSShellScript can't find the file from workingDirectory

image

Your Environment

Additional context

lareeth commented 2 years ago

Can you trying adding disableAutoCwd: true to your AWSShellScript@1 task properties, otherwise the workingDirectory property is ignored

  - task: AWSShellScript@1
    displayName: 'Functional Test'
    inputs:
      awsCredentials: 'terraform-azuredevops-development'
      regionName: 'eu-central-1'
      scriptType: 'filePath'
      arguments: '${{parameters.branch}} ${{parameters.validation}} ${{parameters.dataflow}} ${{parameters.iterations}} $(case1) $(case2) $(case3) $(case4)'
      filePath: ./functional-test.sh
      disableAutoCwd: true
      workingDirectory: '$(System.DefaultWorkingDirectory)/temp/'
JadenSimon commented 2 years ago

Can you trying adding disableAutoCwd: true to your AWSShellScript@1 task properties, otherwise the workingDirectory property is ignored

This is correct though I'd argue it's a bug. We shouldn't be clobbering the working directory if explicitly defined by the user. Having to use a second param to prevent this is unintuitive.

sheldonhull commented 8 months ago

This cost me a few hours of debugging. Be good to have it looked at sometime. Unintuitive behavior compared to other actions. Cheers