Rally Python Api:将讨论添加到缺陷

时间:2013-04-03 20:35:13

标签: python rally pyral

如何使用Pyral为Rally缺陷创建讨论项目?

这是我到目前为止所做的:

rally = Rally(server, user, password)
rally.enableLogging('rallyConnection.log')
rally.setProject("RallyTestPrj")

defectID = 'DE9221'
notes = "Adding new note from Python"
discussion = "Adding discussion from Python"

defect_data = { "FormattedID" : defectID,
                "Notes"       : notes,
                "Discussion"  : discussion
}

try:
defect = rally.update('Defect', defect_data)
except Exception, details:
sys.stderr.write('ERROR: %s \n' % details)
sys.exit(1)
print "Defect updated"

1 个答案:

答案 0 :(得分:0)

实际上,集会中的讨论项目是一个集会工件,就像缺陷,故事或任务一样。为了做你想做的事,你需要创建一个新的讨论工件(或者在拉力赛API术语中使用ConversationPost),并告诉它哪个现有工件(在你的情况下是一个缺陷)与自己关联。

rally = Rally(server, user, password)
rally.enableLogging('rallyConnection.log')
rally.setProject("RallyTestPrj")

defectID = 'DE9221'
discussion_text = "Adding discussion from Python"

# get the defect entity so we can grab the defect oid which we'll need when
# creating the new ConversationPost
defect = rally.get('Defect', query='FormattedID = %s' % defectID, instance=True)

discussion_data = {"Artifact": defect.oid, "Text": discussion_text}

# create the discussion
try:
    discussion = rally.create('ConversationPost', discussion_data)
except Exception, details:
    sys.stderr.write('ERROR: %s \n' % details)
    sys.exit(1)
print "Defect updated with a new discussion entry"