Migrating associated tasks and defects with the user story using python rally API -
we want migrate user stories 1 workspace using api.
import sys pyral import rally, rallyworkset options = [arg arg in sys.argv[1:] if arg.startswith('--')] args = [arg 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 data source user story response = rally.get('userstory', fetch=true, query='formattedid = us2156') rec in response: print(rec.details()) # switch target workspace rally.setworkspace("<target workspace>") rally.setproject("<target project>") print(rec.oid, rec.name, rec.attachments)
used "_ref": rec.ref
see if can associated tasks can migrate them
rec = { "name": rec.name, "attachments": rec.attachments, "schedulestate": rec.schedulestate, "description": rec.description, "_ref": rec.ref } try: userstory = rally.create('userstory', rec) except (rallyrestexception, ex): sys.stderr.write('error: %s \n' % details) sys.exit(1) print("userstory created, objectid: %s formattedid: %s" % (userstory.oid, userstory.formattedid))
i got below exception
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
the objective migrate possible data (associated tasks, defects, test cases, task estimates etc.) when migrate user story
Comments
Post a Comment