代码中的队列Azure devops YAML管道不接受运行时参数 [英] Queue Azure devops YAML pipeline from code does not accept runtime parameters

查看:59
本文介绍了代码中的队列Azure devops YAML管道不接受运行时参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

YAML管道如下所示

YAML pipeline looks like below

parameters:
  - name: parameter1
    type: string
steps:
task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      # Write your PowerShell commands here.
      Write-Host ${{ parameters.parameter1 }}


要排队构建的C#代码就像

C# code to queue build is like

var build = new Build()
            {
                Definition = definition,
                Project = project

            };
var dict = new Dictionary<string, string> { { "parameter1", "parametervalue" } };
build.Parameters = JsonSerializer.Serialize(dict);
buildClient.QueueBuildAsync(build).Wait();

我遇到异常,因为存在验证错误或警告,所以无法将构建排队.必须提供"parameter1"参数的值.解决此问题的任何想法都会有所帮助.

I get exception Could not queue the build because there were validation errors or warnings. A value for the 'parameter1' parameter must be provided. Any idea to fix this issue would be helpful.

推荐答案

看起来目前无法通过C#SDK传递运行时参数来运行管道.您发现使用 REST API .

It looks that this is not possible at the moment to run pipeline with passing runtime parameters over C# SDK. You found workaround using REST API.

这不是SDK的问题.他们以自己的步调发展.因此,REST API中可用的功能并非总是在SDK中同时可用.它可能会在将来推出,但是目前,如果要以编程方式运行它,则需要使用REST API.

This is not an issue with SDK. They are developed in their own pace. So functionality which is available in REST API is not always available at the same moment in SDK. It could be available in the future, but for the moment if you want to run it programmatically you need to use REST API.

这篇关于代码中的队列Azure devops YAML管道不接受运行时参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆