使用 python pyral 为拉力赛缺陷添加标签 [英] Add tag to a Rally Defect using python pyral

查看:18
本文介绍了使用 python pyral 为拉力赛缺陷添加标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 pyral python 包创建 Rally 缺陷.需要添加一个标签#TestTag2".有没有办法在创建缺陷时添加标签?我正在尝试在创建缺陷后添加标签.但是出现以下错误 -

I am trying to create Rally defect using pyral python package. Need to add a tag "#TestTag2". Is there a way to add Tag at the time defect is created? I am trying to add tag after the defect is created. But getting following error -

info = {"Workspace": "/workspace/123",
        "Project": "/project/123",
        "Name": "Test Defect",
        "Description": "Test Defect details",
        "Owner": "/user/123",
        "ScheduleState": "Defined",
        }

try:
    defect = rally.create('Defect', info )
    print ("Rally Defect Opened - {0} \n").format(defect.FormattedID)
    adds = rally.addCollectionItems(defect, 'Tag',"#TestTag")
    rally.addCollectionItems(defect,)
    print(adds)
except Exception, details:
    sys.stderr.write('ERROR: %s \n' % details)
    sys.exit(1)

出现以下错误 -

Rally Defect Opened - DE1234
ERROR: addCollectionItems() takes exactly 3 arguments (4 given) 

请在此处提供帮助,如何为缺陷添加标签.提前致谢.

Please help here, how to add a tag to a defect. Thanks in advance.

推荐答案

你得到这个错误是因为方法的签名如下:

You got this error because of the signature of the method is the following:

def addCollectionItems(self, target, items)

您需要调整代码以传递标签列表:

You need to adjust your code to pass the list of tags:

tag_req = rally.get('Tag', fetch=True, query='Name = "TAG NAME"')
tag = tag_req.next()
adds = rally.addCollectionItems(defect, [tag])

或者您可以在缺陷创建期间直接使用,无需任何额外的 API 调用:

Or you can use directly during Defect creation without any additional API calls:

from pyral import Rally

SERVER = 'SERVER URL'
USER = 'USER'
PASSWORD = 'PASSWORD'
WORKSPACE = 'WORKSPACE'
TAG = 'TAG NAME'
OWNER_EMAIL = 'bla@bla.com'

rally = Rally(SERVER, USER, PASSWORD, workspace=WORKSPACE)

target_project = rally.getProject()

user_req = rally.get('User', fetch=True, query='EmailAddress = "%s"' % (OWNER_EMAIL))
user = user_req.next()

tag_req = rally.get('Tag', fetch=True, query='Name = "%s"' % (TAG))
tag = tag_req.next()

defect_info ={"Project": target_project.ref,
        "Name": "Test Defect",
        "Description": "Test Defect details",
        "ScheduleState": "Defined",
        "Owner": user.ref,
        "TAGS": [tag],
        }

try:
    defect = rally.create('Defect', defect_info )
    print ("Rally Defect Opened - {0} \n").format(defect.FormattedID)
except Exception, details:
    sys.stderr.write('ERROR: %s \n' % details)

这篇关于使用 python pyral 为拉力赛缺陷添加标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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