Create an SCMRepository and Changeset in Web Services API

Document created by JohnStreeter Employee on Jul 27, 2017
Version 1Show Document
  • View in full screen mode
Need instructions on how to create an SCMRepository and Changeset in Web Services API (WS API).
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, 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. 

 

See "Confirm that API Key is working" article for details.

 

Get security token (for OnPremises and Sandbox only)

 

Method: Get
URL:
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": "73bd3465-...."}}

 


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=73bd3465-...

 

Payload (request body):

 

{"SCMRepository":{
"Name":"repo1",
"Description":"created with wsapi",
"SCMType":"sometype",
"Uri":"http://localhost:8080",
"Projects":{"Project":"/project/12527515559"}}
}
}

 

Notice that SCMRepository object has attribute Projects which is a collection of projects, hence this syntax:

 

"Projects":{"Project":"/project/12527515559"}}

 

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/16953479942",
_refObjectUUID: "dff6670a-aedc-4c2b-bd13-16191623c860",
_refObjectName: "repo1",
_type: "SCMRepository"
}

 


We need to use this part: /scmrepository/16953479942

 

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/16953479942",
"CommitTimestamp":"2014-02-11",
"Artifacts":{"Artifact":"/defect/16953278630"}}
}
}

 

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:_abc123" -H "Content-Type: application/json" -d"{\"Changeset\":{\"Revision\":\"1\",\"SCMRepository\":\"/scmrepository/16953479942\",\"CommitTimestamp\":\"2014-12-17\",\"Message\":\"test\",\"Artifacts\":{\"Artifact\":\"/defect/12353153797\"}}}" https://rally1.rallydev.com/slm/webservice/v2.0/changeset/create

 

Attachments

    Outcomes