azure-devops python 运行“create_work_item”时出错
我正在尝试使用 azure-devops python pip 包将大量 Epic/Story/Feature 票证迁移到 Azure Devops。我可以很好地创建单个票证,但我无法通过指定层次结构将这些票证链接在一起(票证 A 是子票证 B/C/D 的父级)
为了创建 EPIC 票证,我正在运行如下代码这:
#set field
jpo = JsonPatchOperation()
jpo.from_ = None
jpo.op = "add"
jpo.path = "/fields/Microsoft.VSTS.Scheduling.FinishDate"
jpo.value = default_field
jpos.append(jpo)
#create work item
createdWorkItem = wit_client.create_work_item(
document=jpos,
project=project.id,
type="EPIC",
validate_only=validate_only,
bypass_rules=bypass_rules,
suppress_notifications=suppress_notifications
)
这有效,但现在我正在尝试弄清楚如何为这张 Epic 门票提供链接的儿童门票。
在这个 azure-devops python 包的 github 存储库中,我可以看到在 create_work_item
的定义中,有一个字符串变量 expand
,它有一个 Relations 选项 < /代码>
<一href="https://github.com/microsoft/azure-devops-python-api/blob/master/azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py#L1578" rel="nofollow noreferrer">https://github.com/microsoft/azure-devops-python-api/blob/master/azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py#L1578
:param str expand: The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }.
中也有讨论create_work_item 函数的官方 azure-devops 文档: https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/create?view=azure-devops-rest-6.0#workitemexpand
但是如果我将 expand='Relations'
添加到我的代码中,这会导致错误:
createdWorkItem = wit_client.create_work_item(
document=jpos,
project=project.id,
type="EPIC",
validate_only=validate_only,
bypass_rules=bypass_rules,
suppress_notifications=suppress_notifications,
expand='Relations'
)
TypeError: WorkItemTrackingClient.create_work_item() got an Unexpected keywords argument 'expand'
我是否正确使用了这个 'expand' 变量?或者是否有其他方法可以使用 python 将儿童票添加到 azure 中的史诗中?谢谢
I am trying to use the azure-devops python pip package in order to migrate a large amount of Epic/Story/Feature tickets into Azure Devops. I can create singular tickets just fine, but I'm having trouble linking those tickets together by specifying the hierarchy (ticket A is a parent to child tickets B / C / D)
In order to create an EPIC ticket I'm running code like this:
#set field
jpo = JsonPatchOperation()
jpo.from_ = None
jpo.op = "add"
jpo.path = "/fields/Microsoft.VSTS.Scheduling.FinishDate"
jpo.value = default_field
jpos.append(jpo)
#create work item
createdWorkItem = wit_client.create_work_item(
document=jpos,
project=project.id,
type="EPIC",
validate_only=validate_only,
bypass_rules=bypass_rules,
suppress_notifications=suppress_notifications
)
Which works, but now I'm trying to figure out how to give this Epic ticket a linked Child ticket.
In the github repo for this azure-devops python package, I can see that in the definition for create_work_item
there is a string variable expand
which has an option for Relations
:param str expand: The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }.
It's also discussed in the official azure-devops documentation for the create_work_item function:
https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/create?view=azure-devops-rest-6.0#workitemexpand
But if I add expand='Relations'
to my code it results in an error:
createdWorkItem = wit_client.create_work_item(
document=jpos,
project=project.id,
type="EPIC",
validate_only=validate_only,
bypass_rules=bypass_rules,
suppress_notifications=suppress_notifications,
expand='Relations'
)
TypeError: WorkItemTrackingClient.create_work_item() got an unexpected keyword argument 'expand'
Am I using this 'expand' variable correctly? Or is there a different way I should add a child ticket to an epic in azure using python? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谢谢用户 Shamrai Aleksander - Stack Overflow。将您的建议作为答案发布以帮助其他社区成员。
要解决此
TypeError: WorkItemTrackingClient.create_work_item() got an Unexpected keywords argument 'expand'
错误:您可以在
patch_document< 中附加关系,而不是使用
expand
/代码>。您可以尝试此示例:参考文献:Azure Python 如何将子/相关票证链接到已创建的票证? - Stack Overflow 和 GitHub - microsoft/azure-devops-python-api: Azure DevOps Python API
Thank you User Shamrai Aleksander - Stack Overflow . Posting your suggestion as an answer to help other community members.
To resolve this
TypeError: WorkItemTrackingClient.create_work_item() got an unexpected keyword argument 'expand'
error:Instead of using
expand
, you can append the relation inpatch_document
. You can try this sample:References: Azure Python how to link child/related tickets to an already created ticket? - Stack Overflow and GitHub - microsoft/azure-devops-python-api: Azure DevOps Python API