Reijer
Reijer

Reputation: 108

cannot locate file in azure devops pipeline

My goal is to

  1. Get postman scripts through an API call in the build stage
  2. Run these scripts in the test stage

I have step 1 working, but I cannot seem to find the files that I pull from the API call. This is the log of the API call to get the postman scripts:

2020-02-11T13:54:34.8779080Z attempting to call Postman API for environment..
2020-02-11T13:54:34.8781038Z file /home/vsts/work/1/a/postman\EA.API.pipeline.json Saved!

This is the result of the run postman script step in the test stage (I try to access both pilot.environment and EA.API.pipeline.json):

error: ENOENT: no such file or directory, open '/home/vsts/work/1/a/postman/environments/pilot.environment.json'

Now an option I have considered is that these directories get wiped between stages. I get the scripts in the build stage, and try to run them in the test stage. This is why after pulling the scripts, I make sure that they are actually in the storage, and afterwards I try to publish them as an artifact:

========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /home/vsts/work/_temp/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx.sh
/home/vsts/work/1/a
├── postman\
├── postman\EA.API.pipeline.json

But in the next step in the same build stage, I try to publish these tests as an artifact, and I get this error:

##[error]Path does not exist: /home/vsts/work/1/a/postman/EA.API.pipeline.json

This is the yaml:

     - task: OneLuckiDev.getPostmanJSON.vsts-release-web-test.oneLuckiGetPostmanScripts@1
        displayName: 'Get Postman Script'
        inputs:
          fileLocation: '$(build.artifactstagingdirectory)/postman'
          apiKey: '$(PostmanAPIKey)'
      - script: 'sudo apt-get install tree'
        displayName: 'install tree'
      - script: 'tree "$(build.artifactstagingdirectory)"'
        displayName: 'run tree'            
      - task: PublishPipelineArtifact@1
        displayName: 'Publish Artifact: postman API tests'
        inputs:
          targetPath: '$(build.artifactstagingdirectory)/postman/EA.API.pipeline.json'
          artifact: PostmanAPITests
          publishLocation: 'pipeline'

Why can't I find my files?

Upvotes: 2

Views: 12135

Answers (1)

gungthar
gungthar

Reputation: 194

This seems to be an issue with your slashes. Your task OneLuckiDev.getPostmanJSON.vsts-release-web-test.oneLuckiGetPostmanScripts@1 seems to have been written for a Windows agent, but you are using a Linux agent. This is causing it to append a backslash when saving your scripts which to your agent is just seen as part of the filename. The file postman\EA.API.pipeline.json is your saved script.

Upvotes: 5

Related Questions