使用python rally API迁移与用户故事相关的任务和缺陷
我们希望使用API将一些用户故事从一个工作区迁移到另一个工作区使用python rally API迁移与用户故事相关的任务和缺陷,python,rally,code-rally,Python,Rally,Code Rally,我们希望使用API将一些用户故事从一个工作区迁移到另一个工作区 import sys from pyral import Rally, rallyWorkset options = [arg for arg in sys.argv[1:] if arg.startswith('--')] args = [arg for arg in sys.argv[1:] if arg not in options] server = "rally1.rallydev.com" apikey = "&l
import sys
from pyral import Rally, rallyWorkset
options = [arg for arg in sys.argv[1:] if arg.startswith('--')]
args = [arg for arg in sys.argv[1:] if arg not in options]
server = "rally1.rallydev.com"
apikey = "<api key>"
workspace = "<Source workspace>"
project = "<target workspace>"
rally = Rally(server,apikey=apikey, workspace=workspace, project=project)
rally.enableLogging('mypyral.log')
# Fetch the data for source user story
response = rally.get('UserStory', fetch=True, query='FormattedID = US2156')
for rec in response:
print(rec.details())
# Switch to target workspace
rally.setWorkspace("<target workspace>")
rally.setProject("<Target Project>")
print(rec.oid, rec.Name, rec.Attachments)
我得到了以下例外
Traceback (most recent call last):
File "migrate.py", line 23, in <module>
userstory = rally.create('UserStory', rec)
File "C:\Users\dedileep\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyral\restapi.py", line 990, in put
itemData = self.validateAttributeNames(entityName, itemData)
File "C:\Users\dedileep\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyral\restapi.py", line 1447, in validateAttributeNames
raise RallyAttributeNameError(", ".join(invalid_attrs))
pyral.restapi.RallyAttributeNameError: _ref
回溯(最近一次呼叫最后一次):
文件“migrate.py”,第23行,在
userstory=rally.create('userstory',rec)
文件“C:\Users\dedileep\AppData\Local\Programs\Python\Python35-32\lib\site packages\pyral\restapi.py”,第990行,输入
itemData=self.validateAttributeNames(entityName,itemData)
validateAttributeNames中第1447行的文件“C:\Users\dedileep\AppData\Local\Programs\Python35-32\lib\site packages\pyral\restapi.py”
raise RALLYATTTRIBUTENAMEERROR(“,”。联接(无效属性))
pyral.restapi.RallyAttributeNameError:\u ref
我们的目标是在迁移用户故事时迁移所有可能的数据(相关任务、缺陷、测试用例、任务估计等)AFAIK TCs、DEs等,这些数据不在工作区之间共享。所以,在你的情况下,它应该被复制。此外,_ref是私有属性,不能被重写。@user2738882-是的,正在复制数据/用户故事,这在我们的例子中也很好。问题是,我们没有得到与驻留在_refobject/property中的任务相关联的任务。是否有任何方式/方法检索此数据?getCollection(collection_url)在这里有帮助吗?只需从现有任务复制粘贴字段,并在刚刚创建的用户情景下使用相同字段创建新任务。无法更改这些对象的引用。
Traceback (most recent call last):
File "migrate.py", line 23, in <module>
userstory = rally.create('UserStory', rec)
File "C:\Users\dedileep\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyral\restapi.py", line 990, in put
itemData = self.validateAttributeNames(entityName, itemData)
File "C:\Users\dedileep\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyral\restapi.py", line 1447, in validateAttributeNames
raise RallyAttributeNameError(", ".join(invalid_attrs))
pyral.restapi.RallyAttributeNameError: _ref