azure devops release stage bash script

Viewed 268

I defined the following stage in my azure devops release : steps:

- bash: |
   # Write your commands here
   
   echo 'Hello world'
   
   curl -X POST -H "Authorization: Bearer dapiXXXXXXXX"  -d @conf/dbfs_api.json  https://adb-YYYYYYYY.X.azuredatabricks.net/api/2.0/jobs/create > file.json
   
  displayName: 'Bash Script'

my repo has a folder called conf with the file dbfs_api.json inside of it , unfortunately this file is not found during the deployment of this stage and I get the following error:

Couldn't read data from file "D:ar1a/conf/dbfs_api.json", this makes an empty POST.
1 Answers

The release stages of an Azure Pipelines workflow don't perform a checkout by default. You can manually add a checkout task to the release stage to perform a checkout:

A deployment job doesn't automatically clone the source repo. You can checkout the source repo within your job with checkout: self. Deployment jobs only support one checkout step.

jobs:
- deployment:
  environment: 'prod'
  strategy:
    runOnce:
      deploy:
        steps:
        - checkout: self 

Or you can create a pipeline artifact in the build stage and consume the artifact in a later artifact.

stages:
- stage: build
  jobs:
  - job:
    steps:
    - publish: '$(Build.ArtifactStagingDirectory)/scripts'
      artifact: drop

- stage: test
  dependsOn: build
  jobs:
  - job:
    steps:
    - download: current
      artifact: drop

See:

Related