2

How to get the list of changes made to a Story or Defect in Rally?

for r in rally.get('User Story', fetch=True, query=""): print r.Changesets

r.Changesets seems to always be an empty collection.

I also tried the rally.get('Revision'...) approach which seems to return me lots and lots of revisions but they do not contain any reference to the object (story/defect/...) being modified.

Also tried to use the query="ObjectID = %s" % r.FormattedID but this always returns nothing.

I also opened a bug on https://github.com/RallyTools/RallyRestToolkitForPython/issues/29 but I am not sure if this will get any attention soon enough.

sorin
  • 161,544
  • 178
  • 535
  • 806

1 Answers1

2

Changeset object, which is a collection of Change objects in WS API is not related to revisions. Those objects are intended for integration with version control systems, e.g. Git, GitHub, Mercurial, Subversion connectors, etc, and have no meaning outside of integration context.

It is possible to traverse from an artifact, e.g. a user story to its revisions using the endpoints below. For example a user story query (FormattedID = US123) :

https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?query=(FormattedID%20%3D%20US123)&fetch=true

will include a reference to RevisionHistory object, redacted for brevity

RevisionHistory: 
{
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/revisionhistory/19382984273", 
_type: "RevisionHistory"
},

This endpoint:

https://rally1.rallydev.com/slm/webservice/v2.0/revisionhistory/19382984273

returns Revision history object that has a referene to Revisions collection

{
RevisionHistory: 
{
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/revisionhistory/19382984273", 
_objectVersion: "3",
CreationDate: "2014-05-29T15:23:21.491Z",
ObjectID: 19382984273,
Revisions: 
{
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/RevisionHistory/19382984273/Revisions", 
_type: "Revision",
Count: 5
}
}
}

Here is an example of Revisions endpoint with narrowed fetch

https://rally1.rallydev.com/slm/webservice/v2.0/RevisionHistory/19382984273/Revisions?fetch=RevisionNumber,User,Description,CreationDate

Generally revision history queries are expensive and we do not recommend using them except in narrow scenarios.

v2.0 removed the ability to return child collections in the same response for performance reasons. Per WS API documentation fetching a collection will return an object with the count and the url from which to get the collection data. To get full objects a separate request is needed.

See this post that mentioned LookbackAPI. LBAPI allows to get historic data. There is no built-in support for LookbackAPI in pyral or any other Rally toolkits except AppSDK2 but LBAPI is language agnostic.

Community
  • 1
  • 1
nickm
  • 5,936
  • 1
  • 13
  • 14
  • I spend quite a few good hours trying to get the revisions out. I need this to migrate some data and parsing Description does not sound good as an approach. I am trying to use the lookback API but it does not return any Revisions. See https://gist.github.com/ssbarnea/bcce8a825f243f8c6c34 this returns 0 revisions for each queried object, even if I do see the revisions in the UI. – sorin Jun 24 '14 at 12:42
  • I agree that parsing revisons descripton is not a good approach, that's why we have LookbackAPI. LBAPI manual is an interactive document where you can test your queries before writing code. There are also examples of using LBAPI endpoints on StackOverflow. Test your queries directly in the browser first, and see if it returns snapshots. In your example you are using both ScheduleState and State when your query object is hierarchicalrequirement. User story does not have State, only ScheduleState. – nickm Jun 24 '14 at 14:54