RedmineでチケットをCSVで一括登録する

すんごいハマったので、メモ。


Redmineでチケットを一括登録したい。


やはりCSVから一括登録出来たらいいよね、とgoogle先生に聞きまくって、
最終的にたどり着いたのが↓のサイト


http://daily-postit.blogspot.com/2010/11/redmine-importer.html



どうも、RedmineCSVインポートのpluginはいろんな人が派生させて作っていて、
Redmineのバージョンによって使えたり、り使えなかったり、日本語がだめだったり、
とまぁ3日間ハマりっぱなしでした。


最終的には、上記サイトに書いてあるpluginを使うことでうまくいきました。


ちなみに自分の使っているRedmineのバージョンは
Redmine 1.1.1.stable」
というやつでした。



インストールはそのままとはいかなくて、


0.依存モジュールを設定
 Redmine CSV Import Pluginを試す | 「世界」旅と子育てとガジェットを愛するエンジニアリングマネージャーのブログ
にある通り、

依存するのがfastercsvなので必要であれば「gem install fastercsv」しておく。

 fastercsvをインストールしておく


1.gitHUBから、pluginをダウンロードする
  上記サイト内の「そちらに変更分を登録してみました」にリンクがあります
  自分の場合は

# wget --no-check-certificate https://github.com/akiko-pusu/redmine_importer/tarball/master

  こんな感じでダウンロード

2.とりあえず解凍して、ディレクトリ名を変えてRedmineに配置

# tar -zxvf akiko-pusu-redmine_importer-7dd533d.tar.gz
# mv akiko-pusu-redmine_importer-7dd533d redmine_importer
# mv redmine_importer /var/lib/redmine/vendor/plugin

  ディレクトリ名をredmine_importerにしないと、plugin実行時に↓のように怒られました(^^;

log/production.logの中身

ActionView::TemplateError (No plugin called 'redmine_importer' - please use the full name of a loaded plugin.) on line #2 of vendor/plugins/akiko-pusu-redmine_importer/app/views/importer/match.html.erb:
1: <% content_for :header_tags do %>
2:     <%= stylesheet_link_tag 'importer', :plugin => 'redmine_importer' %>
3: <% end %>
4:
5: <h2><%= l(:label_match_columns) %></h2>

    vendor/plugins/akiko-pusu-redmine_importer/app/views/importer/match.html.erb:2
    app/helpers/application_helper.rb:856:in `content_for'
    vendor/plugins/akiko-pusu-redmine_importer/app/views/importer/match.html.erb:1
    passenger (3.0.2) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
 ・
 ・
 ・


3.言語ファイルを修正

 なぜか英語の言語ファイルの形式が変になっていたので修正

# cd /var/lib/redmine
# cd vendor/plugins/redmine_importer/
# cd config/locales/
# vi en.yml

 最後の2行の先頭に、スペースを2つ入れる
 これをしないと、サーバ再起動後、Redmineのサイトを見ると

Ruby on Rails application could not be started
These are the possible causes:
There may be a syntax error in the application's code. Please check for such errors and fix them.
A required library may not installed. Please install all libraries that this application requires.
The application may not be properly configured. Please check whether all configuration files are written correctly, fix any incorrect configurations, and restart this application.
A service that the application relies on (such as the database server or the Ferret search engine server) may not have been started. Please start that service.
Further information about the error may have been written to the application's log file. Please check it in order to analyse the problem.
Error message:
undefined method `deep_symbolize_keys' for "Save match rules and submit":String
Exception class:
NoMethodError
Application root:
/var/lib/redmine

 という、むらさきっぽいエラー画面が表示されてしまう。


4.サーバ再起動

 これでインストール終わり。
 自分はApacheで使っているので、Apacheを再起動

# service httpd restart


5.実際にインポート

 Redmineのページからプロジェクトの設定画面へ行き、
 モジュールタブから「Importer」にチェックし保存する。


 するとプロジェクトの目―ニューに「インポート」が出てくるはず。


 実際のインポートは、いろんなサイトに書いてある通り、チケットのCSV出力した
そのままの形式でインポート可能でした

 直すところは
  ・ユーザ名を設定するところは、名前でなくてユーザIDを使う
  ・日付は yyyy-mm-dd
ぐらいでした。
 他のサイトでは「CSVのカラムを必ず""で括らないといけない」とか
書いてありましたけど、特にそんなことなかったです。



 ほんと3日間かけて何にも成果出せてなかったので、うまくいってホント良かった(;_;