Normally a changeset is created in Rally via integration with version control systems. It cannot be created in the UI. It can however be created directly in Web Services API, without using version control integration.
In WS API, the Changeset object has a couple of required fields, one of them an SCMRepository.
SCMRepository is also an object in WS API. It does not have to represent an actual version control repository, e.g, SVN repository.
In this example a browser REST client is used to create an SCMRepository and a Changeset on a defect.
1. Create API Key and use API Key for zsessionid header.
Get security token (for OnPremises and Sandbox only)
Method: GetURL:
https://rally1.rallydev.com/slm/webservice/v2.0/security/authorize
The response will include the token that will be used in the next step:
{"OperationResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [], "Warnings": [], "SecurityToken": "<SECURITY_TOKEN>"}}
2. Create an SCMRepository object:
Method: Post
URL:
https://rally1.rallydev.com/slm/webservice/v2.0/scmrepository/create
(If OnPremises or Sandbox, append the key to the request as in:
https://rally1.rallydev.com/slm/webservice/v2.0/scmrepository/create?key=<SECURITY_TOKEN>
Payload (request body):
{"SCMRepository":{
"Name":"repo1",
"Description":"created with wsapi",
"SCMType":"sometype",
"Uri":"http://localhost:8080",
"Projects":{"Project":"/project/<PROJECT_OID>"}}
}
}
Notice that SCMRepository object has attribute Projects which is a collection of projects, hence this syntax:
"Projects":{"Project":"/project/<PROJECT_OID>"}}
After SCMRepository is created find out its reference. A query on SCMReposotory objects in WS API will return existing repositories. Here is an example of a return:
{
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/scmrepository/<OBJECT_OID>",
_refObjectUUID: "<OBJECT_UUID>",
_refObjectName: "repo1",
_type: "SCMRepository"
}
We need to use this part:
/scmrepository/<OBJECT_OID>
3. Create a Changset:
Changest object in WS API has required fiels: CommitTimeStamp, Revision, SCMRepository. Artifacts attribute, which is a collection of artifacts with which changeset is associated is not a required field.
Method: Post
URL:
https://rally1.rallydev.com/slm/webservice/v2.0/changeset/create
Payload (request body):
{"Changeset":{
"Revision":"1",
"SCMRepository":"/scmrepository/<OBJECT_OID>",
"CommitTimestamp":"2014-02-11",
"Artifacts":{"Artifact":"/defect/<DEFECT_OID>"}}
}
}
A changeset is created:
Here is an example of creating a changeset with a curl command (API key is used for authentication):
curl --header "zsessionid:<API Key - include the underscore before the key>" -H "Content-Type: application/json" -d"{\"Changeset\":{\"Revision\":\"1\",\"SCMRepository\":\"/scmrepository/<OBJECT_OID>\",\"CommitTimestamp\":\"2014-12-17\",\"Message\":\"test\",\"Artifacts\":{\"Artifact\":\"/defect/<DEFECT_OID>\"}}}" https://rally1.rallydev.com/slm/webservice/v2.0/changeset/create