How to delete a changeset
search cancel

How to delete a changeset

book

Article ID: 57554

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

A wrong artifact was referenced in the commit message and now this artifact has a changeset associated with it. How to delete or unlink a changeset? There is no "Delete" option in the Changeset tabs of User Stories and Defects.
 

 

Resolution

Changesets can be created and deleted via Web Services API. There are no equivalent options in the UI. Editor rights are sufficient

In this example we create a new changeset using a curl command. It is more likely that the changeset that you would like to delete has been created by one of the CA Agile Central's source code integrations, but for the purposes of this article it makes no difference whether a changeset was created via a connector, custom app or by hitting the create endpoint directly.
In this example curl command uses Api Key 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_ID>\",\"CommitTimestamp\":\"2014-12-17\",\"Message\":\"worked on DE4\",\"Artifacts\":{\"Artifact\":\"/defect/<DEFECT_OID>\"}}}" https://rally1.rallydev.com/slm/webservice/v2.0/changeset/create



Changeset is created successfully.  Now we are going to delete it. To delete a changeset we need to identify it by ObjectID. Here is an example of a WS API query:

(Message = "worked on DE4")



Now we can delete the changeset. Here is the command:

curl --header "zsessionid:<API Key - include the underscore before the key>" -H "Content-Type: application/json" -X DELETE https://rally1.rallydev.com/slm/webservice/v2.0/changeset/<CHANGE_SET_OID>


The absence of WS API errors and curl errors indicates a success:

{"OperationResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [],"Warnings": []}}


The changeset is gone.

 

Below is a Ruby code fragment example that bulk-deletes changesets returned by a query
(Message contains \"DE4\")

Warning: this code deletes data. Make sure that the query returns the changesets you intend to delete!

@rally = RallyAPI::RallyRestJson.new(config)


#find changesets that meet criteria
query = RallyAPI::RallyQuery.new()
query.type = "changeset"
query.fetch = "ObjectID,Message"
query.query_string = "(Message contains \"DE4\")"

results = @rally.find(query)
changesets_to_delete = [];
results.each do |c|
  puts "ObjectID: #{c["ObjectID"]}, Message: #{c["Message"]}"
  c.read
  changesets_to_delete << c
end

#delete changesets
changesets_to_delete.each do |c|
  puts "deleting... #{c["_ref"]}"
  c.delete
end

 

The full code example is available in this github repo.