Search code examples
azure-devopsazure-pipelinesazure-pipelines-yamlazure-yaml-pipelines

How to run a pipeline with parameters


In Azure Devops Server 2019, I have a build written in yaml in the Pipelines/Builds section. It's possible to enter some parameters values through a ui using the "Run with parameters" option.
In Azure Devops Server 2022, the same kind of action doesn't seem possible: there's no "Run pipeline with parameters" option.
Is it possible to enter values before running a pipeline?


Solution

  • Sure, on Azure DevOps Server 2022, you can define parameters in the YAML pipelines and manually enter the values when manually triggering the pipelines.

    See below example as reference.

    1. The pipeline main YAML.

      # azure-pipelines.yml
      
      parameters:
      - name: myParam
        displayName: 'Enter the value of your parameter:'
        type: string
        default: 'ABC123'
      
      steps:
      - script: |
          echo "myParam = ${{ parameters.myParam }}"
        displayName: 'Print parameters'
      
    2. When manually trigger the pipeline (include calling the related Azure DevOps API/CLI to trigger):

      • Can keep the default parameter value.

        enter image description here

      • Can enter a different parameter value to overwrite the default value.

        enter image description here

    3. If the pipeline is automatically triggered, it will use the default parameter value.

    The version of my Azure DevOps Server 2022 is Version Azure DevOps Server 2022.1 (AzureDevOpsServer_20231109.2). It's not the current latest version but can work as expected. You can try to upgrade yours to the latest version and then check if it can work like as above example.