0

I have a JSON called config.json and I would like to use the values it has to shit variables in a YML.

This is the format of the JSON

{
 "config": 
 {
   "ruta": "releases/package.xml",
   "testLevel": "--testlevel NoTestRun",
   "destroy": "false"
 }
}

I need to get the value of "destroy" and load it into a variable in a YML.

Here I have a breakthrough and I need to use that variable in the next stage called "Validation" so that the condition is met.

stages:
 - stage: LoadEnv
   displayName: Load environment variables
   jobs:
   - job: 

     variables: 
     - name: DESTROY
       value: false

   steps:
    - task: FileTransform@1
      inputs:
        folderPath: '$(System.DefaultWorkingDirectory)'
        targetFiles: 'azure/config.json'
        fileType: 'json'

    - script: echo ${{variables.DESTROY}}     

 - stage: Validation
   displayName: Validate environment
   condition: eq( dependencies.LoadEnv.outputs['Load.variables.DESTROY'], 'false')
   jobs: 
   - job: Validation
     .......

I know things are missing but any help is welcome.

  • SOLUTION!!! https://stackoverflow.com/questions/70133976/azure-pipeline-read-values-from-json-file-in-the-repo-and-store-it-in-pipeline – Felipe Peña Sep 27 '22 at 01:21
  • Does this answer your question? [import Azure Devops pipeline variables from json file](https://stackoverflow.com/questions/58597755/import-azure-devops-pipeline-variables-from-json-file) – Tejas Nagchandi Sep 29 '22 at 14:22
  • Thank you very much, I used the option but when I declare the variable, it returns null. – Felipe Peña Oct 20 '22 at 23:00

0 Answers0