【问题标题】:Add tag to a Rally Defect using python pyral使用 python pyral 将标签添加到 Rally 缺陷
【发布时间】:2018-03-22 17:06:13
【问题描述】:

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

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) 

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

【问题讨论】:

  • 请看下面的答案。如果它对您有用,请将其标记为答案。谢谢!

标签: python tags pyral


【解决方案1】:

您收到此错误是因为方法的签名如下:

def addCollectionItems(self, target, items)

你需要调整你的代码来传递标签列表:

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

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

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)

【讨论】:

  • 嗨,使用上述方法时出现以下错误 -
  • 您能粘贴完整的堆栈跟踪吗?很难说没有错误。在您的评论中,仅打印对象...
猜你喜欢
  • 2013-07-29
  • 2012-09-21
  • 1970-01-01
  • 1970-01-01
  • 2019-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多