Home > front end >  Passing values from json file to Azure pipeline variables
Passing values from json file to Azure pipeline variables

Time:12-16

I have a pipeline in azure that is triggered by commit on specific folder in repository. In this folder there is a file.json with example values:

{
    "example": {
        "vaule1": "one",
        "vaule2": "two",
}
}

how can I pass those values to pipeline and set them as global variable or parameter

name: "test"

trigger: none

variables: 
  value1: ''
  value2: ''
  
jobs:

  - job: example_job
    displayName: 'example_job'
    condition: eq('${{ variables.value1}}', 'false')

    steps:
    - checkout: self

CodePudding user response:

The global pipeline variables and parameters must be set before the pipeline has been triggered. It is not possible to set them during the run time.

As a workaround, you can try like as below:

  1. Set a job as the very first job of your pipeline. And in this job, you can try to parse the Json file to get the values and set the values as output variables of the pipeline.

  2. Set other jobs to depend on the first job so that they can use the output variables generated in the first job.

For more details, you can refer the document about "enter image description here

  • Related