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 => "harsha.gowda@xyz.com",  :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
user1417835
  • 1,002
  • 1
  • 8
  • 14
harsha
  • 33
  • 1
  • 4
  • .Net API does this [http://stackoverflow.com/questions/7825345/how-to-create-a-task-belonging-to-an-iteration-using-rally-api-and-net][1] . Not sure of doing same in ruby [1]: http://stackoverflow.com/questions/7825345/how-to-create-a-task-belonging-to-an-iteration-using-rally-api-and-net – harsha Sep 04 '12 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? – user1417835 Sep 04 '12 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 04 '12 at 20:12

1 Answers1

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.

user1417835
  • 1,002
  • 1
  • 8
  • 14