通过Pyral向拉力赛添加任务

时间:2012-09-20 04:47:48

标签: python api rally pyral

我对Rally相当新,并且一直在测试它。我一直在寻找他们的python框架来使用他们的API。不幸的是,在文档中我找不到添加任务的方法。

之前有没有人曾经使用过这个,或者有人能建议通过API导入任务的简单方法吗?目前,我有一个完整的电子表格,其中的任务遵循其csv模板以导入数据。

1 个答案:

答案 0 :(得分:6)

Rally Task项必须与WorkProduct相关联(通常是像HierarchicalRequirement(又名UserStory),Defect或TestCase这样的Artifact)。使用pyral工具包,一旦获得Rally实例,获取与该任务相关联的Workspace,Project和WorkProduct的对象引用,然后使用这些项以及其他所需的Task属性填充Python dict并将其抛出在拉力赛。

任务创建配方:

[insert your boilerplate code for dealing with command line args, Rally options, etc]
rally = Rally(server, username, password, workspace=workspace, project=project)
artifact_ident = args.pop()  # get the FormattedID of an artifact as the Task relation target
wksp = rally.getWorkspace()
proj = rally.getProject()

artifact = rally.get("UserStory", fetch="FormattedID", 
                                  query='FormattedID = "%s"' % artifact_ident,
                                  instance=True)
# for a Task, the Workspace, Project, WorkProduct, Name, State and TaskIndex attributes
# are required. The Workspace, Project and WorkProduct attributes must be supplied as
# valid Rally object references.  
info = { "Workspace"   : wksp.ref,
         "Project"     : proj.ref,
         "WorkProduct" : artifact.ref,
         "Name"        : "Scrape vanilla bean",
         "State"       : "Defined",
         "TaskIndex"   : 1,
         "Description" : "With a dull knife, strip material from the vanilla bean"
       }
task = rally.put('Task', info)
print "Created Task: %s  associated with UserStory %s" % (task.FormattedID, artifact.FormattedID)