如何在Azure开发流水线任务中运行WIQL查询?任何例子



我有一个管道,我需要查询我使用rest api的工作项,但我不确定如何使用Azure管道任务。我的是一个linux代理,因此,是否有可能在shell中运行它而不是powershell?

您可以在shell脚本或类似的管道任务中运行WIQL查询。

创建一个没有换行符的Json,像

{
"query": "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Task' AND [State] <> 'Closed' AND [State] <> 'Removed' order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc"
}

和以下内容一起发送:

#!/bin/bash
source ~/bin/variables.sh
url="https://dev.azure.com/$(organizationName)/$(project)/_apis/wit/queries/{query}?api-version=7.0"    
response=$(curl -s -u $(presenter):$(PAT) -X POST -H "Content-Type: application/json" -d "${json}" "${url}")

organizationName为组织名称。

project为项目名称。

presenter是user.name (from az account show)

PAT为个人访问令牌。

对于在PowerShell脚本中使用Azure pipeline运行查询,可以参考这个ticket在Azure- devops中运行pipeline查询。

对于使用Linux Shell脚本运行Azure DevOps Service REST API,您可以参考此票证使用Linux Shell脚本创建Azure DevOps Service REST API的拉取请求。

希望对你有帮助。

最新更新