0

From the below sample code i am able to test the working to list all Tasks in a project.

I want to add New tasks Automatically under a User Story US1234.

I have some 50 User Story in excel to Enter with Task fields (Name ,description, estimate ,To do ,etc... ) ,I want to automate this work.

How to create a task under a user story with the Task fields using REST api in ruby.

There was not much of help with this link http://developer.rallydev.com/help/ruby-toolkit-rally-rest-api

require 'rubygems'
require 'rally_rest_api'

rally= RallyRestAPI.new(:base_url =>"https://rally1.rallydev.com/slm",  :username => "[email protected]",  :password => "xyz123")
projects  = rally.find(:project) { equal:name, "XYZ Engineering - Scrum Team 2"}

projects.each do |project| 
 #  puts project.name   

   tasks = rally.find(:task, :project => project, :fetch => true) {equal :State, "Defined"}


   tasks.each do |task| 
       puts task.name
   end


end
3
  • .Net API does this [stackoverflow.com/questions/7825345/… . Not sure of doing same in ruby [1]: stackoverflow.com/questions/7825345/…
    – harsha
    Sep 4, 2012 at 19:53
  • So you have a set of empty tasks that need to have their fields set? Is this the issue? Are they all going to receive the same field values? Sep 4, 2012 at 19:57
  • yes these tasks need to be added for a user story for this sprint, All task have different field values but show me how to add a task under a user story so that i can automatically add task's than manually clicking and entering the name description etc....
    – harsha
    Sep 4, 2012 at 20:12

1 Answer 1

1

You should be able to find most of the answers to your questions here: http://rally-rest-api.rubyforge.org/crud.html.

Here is a basic example, which iterates through each Task on a User Story:

require 'rubygems'
require 'rally_rest_api'

rally= RallyRestAPI.new(:base_url => url,  :username => user,  :password => pw)
project  = (rally.find(:project) { equal :name, name}).first()

rally.find(:hierarchical_requirement, :project => project) {equal :some_field, some_value}.each{ |hr|
    hr.tasks.each{ |task|
        task.update(:some_field1 => some_value1)
        task.update(:some_field2 => some_value2)
        task.update(:some_field3 => some_value3)
        task.update(:some_field4 => some_value4)
    }
}

I don't know how you intend on updating each individually, so you'll have to modify it with your own logic.

2
  • Thanks for the reply can you help me with an example to create Task under an existing user story US1234 where i can specify the to do description etc...
    – harsha
    Sep 4, 2012 at 20:57
  • Updated with generic example. Sep 4, 2012 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.