Anil
Anil

Reputation: 61

file does not exists in Command line Task in Azure build pipeline

I am trying to use CMD task in azure build pipeline to execute the script which is stored in Azure Repo. When I run the build pipeline, cmd task throws below error:

 An error occurred: The file D:\a\1\s\_JmeterTest-AG\JmeterWebApp.jmx doesn't exist or can't be opened

I have checked JmeterWebApp.JMX does exists in my Azure Repo (JmeterTest-AG).

My CMD task details as follows:

**- task: CmdLine@2
  inputs:
      script: |
        echo 'Jmeter............'
        jmeter -n -t $(Build.SourcesDirectory)/_JmeterTest-AG/JmeterWebApp.jmx -l _JmeterTest-AG/Summary.jtl -e -o HTMLReports**```

Upvotes: 0

Views: 1002

Answers (1)

Vito Liu
Vito Liu

Reputation: 8278

Repo directory structure

enter image description here

Power shell script:

trigger:
- master

pool:
  vmImage: ubuntu-latest

steps:
- task: CmdLine@2
  inputs:
    script: |
      echo 'Jmeter............'
      jmeter -n -t $(Build.SourcesDirectory)/_JmeterTest-AG/JmeterWebApp.jmx -l _JmeterTest-AG/Summary.jtl -e -o HTMLReports**```

Note: Then path $(Build.SourcesDirectory) is D:\a\1\s, we need to ensure that the folder _JmeterTest-AG is at the root path and it contain the file JmeterWebApp.jmx, then we will not see the error message.

In addition, we need to ensure that the file can open and run successfully, you can create the same file on your local machine and run the cmd.

Upvotes: 1

Related Questions