I am absolutely new to Azure Devops, but was able to create a pipeline with stages. In the config.yml file, is it also possible to indicate separate parameters for each stage?
This is a snippet of the pipeline where it uses a script inside a stage:
- stage: Configure_Iflow_in_QA
dependsOn: Copy_Iflow_to_QA_Package
jobs:
- job: Configure_Iflow_in_QA
variables:
- group: development
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Cache@2
inputs:
key: piper-go-official
path: bin
displayName: Configure_Iflow_in_QA
- script: |
bin/piper integrationArtifactUpdateConfiguration --verbose true --apiServiceKey $(CREDENTIALS) --integrationFlowId "Test_Iflow1_QA"
And here is the config file:
steps:
integrationArtifactUpload:
integrationFlowId: 'Test_Iflow1_QA'
integrationFlowName: 'Test Iflow1 QA'
packageId: 'CICD2'
integrationArtifactUpdateConfiguration:
integrationFlowId: 'Test_Iflow1_QA'
integrationFlowVersion: 'Active'
parameterKey: 'LogEnabled'
parameterValue: 'true'
But what if I wanted to use the script integrationArtifactUpdateConfiguration again in a different stage with different parameters?
2
Answers
You can specify parameters and their data types in a template, which allows you to reuse not only stages but also variables, steps, and jobs.
Example:
/pipelines/stages/hello-world-stage.yaml
Defining the stages template with multiple parameters:
hello-world-pipeline.yaml
Using the stages template:
If you have piper config.xml content and would like to use
different parameters
for stages, you need to:placeholder
as the value in config.xml.replacetokens@6
to replace the value for each stage.The config.xml sample:
In the DevOps yaml:
You can add more placeholder in the config.xml if needed. use same named variable in each stage for replacement.