0

We want to migrate some user stories from one workspace to another using 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 = "<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)

Used "_ref": rec.ref to see if I can get the associated tasks so that I can migrate them as well

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 is to migrate all the possible data (associated tasks, defects, test cases, task estimates etc.) when we migrate the user story

jvillian
  • 19,953
  • 5
  • 31
  • 44
Darshan Deshmukh
  • 353
  • 1
  • 4
  • 15
  • AFAIK TCs, DEs and etc. not shared between Workspaces. So, in your cases it should be copied. Furthermore, _ref is private property and cannot be overridden. – user2738882 Apr 08 '17 at 07:08
  • @user2738882 - Yes true, the data/user story is being copied which is also fine in our case. The issue is we are not getting associated tasks along with it which resides in _ref object/property. Is there any way/method to retrieve this data? Does getCollection(collection_url) help here ? – Darshan Deshmukh Apr 09 '17 at 12:49
  • Just copy-paste fields from existing Task and create new Task under just created User Story with the same fields. No way to change ref for these objects. – user2738882 Apr 09 '17 at 17:11

0 Answers0