使用 Azure Devops REST API 创建交付计划样式规则

问题描述 投票:0回答:2

我正在尝试使用 Azure Devops REST API 在 Azure Devops 项目中创建交付计划。我使用以下方法来创建相同的。

https://learn.microsoft.com/en-us/rest/api/azure/devops/work/plans/create?view=azure-devops-rest-6.0

POST https://dev.azure.com/{organization}/{project}/_apis/work/plans?api-version=6.0

我正在请求正文属性中发送以下数据

{
    "properties": {
        "teamBacklogMappings": [
            {
                "teamId": "09d57738-697f-4433-abdd-b80a2bc6337b",
                "categoryReferenceName": "Microsoft.RequirementCategory"
            },
            {
                "teamId": "5df45eec-4108-474a-8d93-bc09c0b9037e",
                "categoryReferenceName": "Microsoft.RequirementCategory"
            },
            {
                "teamId": "e8ed402b-68e7-4140-96f2-07790a08788b",
                "categoryReferenceName": "Microsoft.RequirementCategory"
            },
            {
                "teamId": "14425694-efa5-454e-811c-e9e03d79198f",
                "categoryReferenceName": "Microsoft.RequirementCategory"
            },
            {
                "teamId": "b02690e9-1f48-421a-a918-3b23cc9a1b73",
                "categoryReferenceName": "Microsoft.RequirementCategory"
            }
        ],
        "cardSettings": {
            "fields": {
                "showId": true,
                "showAssignedTo": true,
                "assignedToDisplayFormat": "avatarOnly",
                "showState": true,
                "showTags": true,
                "showParent": false,
                "showEmptyFields": true,
                "showChildRollup": true,
                "additionalFields": null,
                "coreFields": [
                    {
                        "referenceName": "System.AssignedTo",
                        "displayName": "Assigned To",
                        "fieldType": "string",
                        "isIdentity": true
                    },
                    {
                        "referenceName": "System.Id",
                        "displayName": "ID",
                        "fieldType": "integer",
                        "isIdentity": false
                    },
                    {
                        "referenceName": "System.State",
                        "displayName": "State",
                        "fieldType": "string",
                        "isIdentity": false
                    },
                    {
                        "referenceName": "System.Tags",
                        "displayName": "Tags",
                        "fieldType": "plainText",
                        "isIdentity": false
                    }
                ]
            }
        },
        "markers": [],
        "styleSettings": [
            {
                "name": "BLOCKER",
                "isEnabled": "True",
                "filter": "[System.Tags] CONTAINS 'BLOCKER'",
                "clauses": [
                    {
                        "fieldName": "System.Tags",
                        "logicalOperator": "AND",
                        "operator": "CONTAINS",
                        "value": "BLOCKER"
                    }
                ],
                "settings": {
                    "background-color": "#E60017",
                    "title-color": "#000000"
                }
            },
            {
                "name": "New",
                "isEnabled": "True",
                "filter": "[System.State] = 'New'",
                "clauses": [
                    {
                        "fieldName": "System.State",
                        "logicalOperator": "AND",
                        "operator": "=",
                        "value": "New"
                    }
                ],
                "settings": {
                    "background-color": "#AAAAAA",
                    "title-color": "#000000"
                }
            },
            {
                "name": "Dev Completed",
                "isEnabled": "True",
                "filter": "[System.State] = 'Development Completed'",
                "clauses": [
                    {
                        "fieldName": "System.State",
                        "logicalOperator": "AND",
                        "operator": "=",
                        "value": "Development Completed"
                    }
                ],
                "settings": {
                    "background-color": "#D7E587",
                    "title-color": "#000000"
                }
            },
            {
                "name": "Deployed to QA",
                "isEnabled": "True",
                "filter": "[System.State] = 'Deployed to QA (SIT)'",
                "clauses": [
                    {
                        "fieldName": "System.State",
                        "logicalOperator": "AND",
                        "operator": "=",
                        "value": "Deployed to QA (SIT)"
                    }
                ],
                "settings": {
                    "background-color": "#C3D84C",
                    "title-color": "#000000"
                }
            },
            {
                "name": "Deployed to UAT",
                "isEnabled": "True",
                "filter": "[System.State] = 'Deployed to UAT'",
                "clauses": [
                    {
                        "fieldName": "System.State",
                        "logicalOperator": "AND",
                        "operator": "=",
                        "value": "Deployed to UAT"
                    }
                ],
                "settings": {
                    "background-color": "#60AF49",
                    "title-color": "#000000"
                }
            },
            {
                "name": "Deployed to PROD",
                "isEnabled": "True",
                "filter": "[System.State] = 'Completed'",
                "clauses": [
                    {
                        "fieldName": "System.State",
                        "logicalOperator": "AND",
                        "operator": "=",
                        "value": "Completed"
                    }
                ],
                "settings": {
                    "background-color": "#00643A",
                    "title-color": "#000000"
                }
            }
        ],
        "tagStyleSettings": []
    }
}

但是,样式规则并未在项目中创建。

azure-devops-rest-api
2个回答
1
投票

创建交付计划后立即使用交付计划更新来完成此操作。使用相同的属性更新它,但您必须将修订属性添加到请求正文。 https://learn.microsoft.com/en-us/rest/api/azure/devops/work/plans/update?view=azure-devops-rest-6.0

https://dev.azure.com/{organization}/{project}/_apis/work/plans/{id}?api-version=6.0


0
投票

创建交付计划不接受样式设置,从 UI 中您可以注意到:

只需从Create API获取计划ID和响应,然后在Update API中使用它们,这是唯一的方法。

© www.soinside.com 2019 - 2024. All rights reserved.