用户PowerShell在Azure Devops中将生成排队 [英] User PowerShell to Queue a Build in Azure Devops

查看:79
本文介绍了用户PowerShell在Azure Devops中将生成排队的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

堆栈中有一些相关的问题,下面将其丢弃.我正在使用Azure DevOps api 5.1并尝试将生成排队.

There are a few related questions in stack I'll drop them below. I'm working with Azure DevOps api 5.1 and attempting to queue a build.

{
    "Definition": {
        "id": "7"
    }
}

这将使构建与定义中已设置的变量一起排队.我试图以几种不同的方式传递变量,但这两种方法最终都没有被API认可.

This will queue a build with the variables that are already set in the definition. I have attempted to pass in variables in a few different ways both of which wound up not being honored by the API at all.

{
    "Definition": {
        "id": "7",
        "variables": {
            "tag": "@{value=v1.1.0}",
            "system.debug": "@{value=true}"
        }
    }
}

根据我也尝试过的一些相关问题

Per some of the related questions I also attempted

{
    "Definition": {
        "id": "7",
        "parameters": {
            "tag": "@{value=v1.1.0}",
            "system.debug": "@{value=true}"
        }
    }
}

在通过UI对构建进行排队时捕获了chrome的输出后,它似乎期望变量而不是参数,但是当我返回查看构建时,我看到的是正在传递的变量没有被荣幸.另外,我采用了我希望运行的定义,并将其隐藏在上面的body.definition中.

After capturing the output from chrome while queuing a build via the UI it appears to expect variables as opposed to parameters, but what i'm seeing when i go back to view the builds is that the variables being passed in are not being honored. Additionally I have taken the definition I wish to run and stashed it into the body.definition above.

VSTS使用API​​在队列中设置构建参数时间

TFS 2017 API;用变量排队构建

如何使用VSTS REST排队新的构建API

请让我知道是否应该添加更多细节,我没有放置实际的代码,但这很简单

Please let me know if I should add more detail I've not put the actual code, but it is pretty straightforward

Invoke-RestMethod -Method post -Uri $uri -Headers $Header -ContentType 'application/json' -Body ($Body |ConvertTo-Json -Compress -Depth 10)

推荐答案

解雇邮递员并找到一个集合后,我试图传递变量的方式似乎有两个问题.

After firing up postman and finding a collection it appears there were two issues with how I was attempting to pass the variables.

问题1:变量与参数

即使基于此处的几个问题,以及捕获从网络浏览器到开发人员的访问量,也是如此.您不能将变量用作定义的一部分,它必须是参数.另外,似乎它们不能嵌套在定义(body.definition.parameters)内,它们必须与定义(body.parameters)处于同一级别.

Even though based on several questions here as well as capturing the traffic from web browser to devops. You cannot use variables as a part of the definition, it must be parameters. Additionally it appears that they cannot be nested inside the definition (body.definition.parameters) they must be at the same level as defintions (body.parameters).

问题2:格式

参数值必须压缩为json,此外,它不能是对象,而必须是variable:value.

The parameters value must be compressed json, additionally it cannot be an object, it must be variable:value.

{
    "definition": {
        "id": 7
    },
    "parameters": "{\"tag\":\"v3.2.1\"},\"system.debug\":\"true\"}"
}

我觉得我之前在上面发布的一个相关问题中已经看过这个答案了.对所有重复的工作表示歉意.

I feel I've seen this answer before possibly in one of the related questions I posted above. Apologies for all the duplication of effort.

这篇关于用户PowerShell在Azure Devops中将生成排队的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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