0

Ruby スクリプトと Rally Rest API を使用して、Rally v12.4 の欠陥を削除できます。その後、欠陥はごみ箱に入ります。どうすれば完全に削除できますか?

知っておく必要がある場合... ClearQuest からデータをインポートしています (Enterprise editino を使用し、CQ コネクタを持っていません)。マッピングを処理する際に、小さなバッチをインポートして、それがどのように機能するかを確認します。これを繰り返しますが、毎回すべての欠陥をクリアしたいと考えています。それらを削除する Ruby スクリプトを作成しましたが、ごみ箱から削除されず、1 つずつ実行する必要があります。何百もの ClearQuest チケットを移行した後で問題が見つかった場合、それらをごみ箱から 1 つずつ削除したくありません。

繰り返しになりますが、答える質問は、「どうすれば完全に削除できますか?」ということです。

4

1 に答える 1

0

次のスクリプトは、このタスクの実行に役立つ場合があります。

# Usage: ruby rally_empty_recycle_bin.rb
# Specify the User-Defined variables below. Script will iterate through all items in
# Rally Recycle bin for specified Workspace and Project, and prompt the user to confirm
# permanent deletion of the item of interest.

require 'rally_api'

$my_base_url       = "https://rally1.rallydev.com/slm"
$my_username       = "user@company.com"
$my_password       = "password"
$my_workspace      = "My Workspace"
$my_project        = "My Project"
$wsapi_version     = "1.41"

# Make no edits below this line!!
# =================================

#Setting custom headers
$headers                            = RallyAPI::CustomHttpHeader.new()
$headers.name                       = "Rally Empty Recycle Bin"
$headers.vendor                     = "Rally Labs"
$headers.version                    = "0.50"

# Load (and maybe override with) my personal/private variables from a file...
my_vars= File.dirname(__FILE__) + "/my_vars.rb"
if FileTest.exist?( my_vars ) then require my_vars end

begin

  #==================== Make a connection to Rally ====================

  config                  = {:base_url => $my_base_url}
  config[:username]       = $my_username
  config[:password]       = $my_password
  config[:workspace]      = $my_workspace
  config[:project]        = $my_project
  config[:version]        = $wsapi_version
  config[:headers]        = $headers

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

  # Lookup source Test Folder
  recycle_bin_query = RallyAPI::RallyQuery.new()
  recycle_bin_query.type = :recyclebin
  recycle_bin_query.fetch = true

  recycle_bin_query_results = @rally.find(recycle_bin_query)

  number_recycle_bin_items = recycle_bin_query_results.total_result_count

  if number_recycle_bin_items == 0
    puts "No items found in Recycle Bin. Exiting."
    exit
  end

  puts "Found #{number_recycle_bin_items} items in Recycle Bin for possible deletion."
  puts "Start processing deletions..."

# Loop through matching artifacts and delete them. Prompt user
# for each deletion.

  number_processed = 0
  number_deleted = 0
  affirmative_answer = "Y"

  recycle_bin_query_results.each do | this_recycle_bin_item |

    number_processed += 1
    puts "Processing deletion for item #{number_processed} of #{number_recycle_bin_items}."

    item_formatted_id = this_recycle_bin_item["ID"]
    item_name = this_recycle_bin_item["Name"]
    item_type = this_recycle_bin_item["Type"]
    puts "Deleting Item #{item_formatted_id}, #{item_type}: #{item_name}..."
    puts this_recycle_bin_item["_ref"]
    really_delete = [(print "Really delete? [Y/n]:"), gets.rstrip][1]

    if really_delete == affirmative_answer then
      begin
        delete_result = @rally.delete(this_recycle_bin_item["_ref"])
        puts "DELETED #{item_formatted_id}: #{item_name}"
        puts delete_result
        number_deleted += 1
      rescue => ex
        puts "Error occurred trying to delete: #{item_formatted_id}: #{item_name}"
        puts ex.backtrace
      end
    else
      puts "Did NOT delete #{item_formatted_id}: #{item_name}."
    end
  end

  puts
  puts "Deleted a total of #{number_deleted} items from the Recycle Bin."
  puts "Complete!"

end
于 2013-03-28T13:59:19.587 に答える