Redmine 5.0.0リリース
先月末の3月28日に、Redmine 5.0.0がリリースされていたことを知りました。
Redmine 5.0.0 リリース | Redmine.JP Blog
今回のメジャーバージョンアップでは、Rails 5.2から6.1への移行がなされ、合わせて Zeitwerkというオートロードに対応したとのことです。従来のclassicオートローダーはRails 6では非推奨で、Rails 7で廃止となります。この変更で、一部のプラグインが動作しなくなりプラグイン側で修正が必要となります。
その他、多数新機能が追加されています。
Redmine 4.2から5.0へのアップデート
Rocky Linux 8.5上で稼働しているRedmine 4.2(Unicorn + Nginx)を、Redmine 5.0にアップデートします。およその手順は次です。
- Redmine 5.0 を github からクローン
- Redmine 4.2のディレクトリから設定ファイルをRedmine 5.0のディレクトリへコピー
- Redmine 4.2 のディレクトリ下からプラグインをRedmine 5.0のディレクトリへコピー
- Redmine 4.2のディレクトリからテーマファイルをRedmine 5.0のディレクトリへコピー
- Redmine 5.0のディレクトリで必要なgemsをインストール
- Redmine 5.0 のディレクトリで、5.0に非対応なプラグインをチェック
- 非対応なプラグインの処置
- Redmine 5.0のディレクトリでマイグレート実行
- Redmine 4.2のディレクトリから添付ファイルをRedmine 5.0のディレクトリへコピー
- Unocorn 起動設定ファイルのパスを変更
Redmine 5.0 を github からクローン
~$ cd /var/lib lib$ sudo git clone -b 5.0-stable https://github.com/redmine/redmine.git redmine-5.0-stable lib$ sudo chown -R redmine:redmine redmine-5.0-stable/
Redmine 4.2のディレクトリから設定ファイルをRedmine 5.0のディレクトリへコピー
redmine-5.0-stable$ cp -p ../redmine-4.2-stable/config/configuration.yml config redmine-5.0-stable$ cp -p ../redmine-4.2-stable/config/database.yml config redmine-5.0-stable$ cp -p ../redmine-4.2-stable/config/unicorn.rb config redmine-5.0-stable$ cp -p ../redmine-4.2-stable/config/additional_environment.rb config redmine-5.0-stable$ cp -p ../redmine-4.2-stable/Gemfile.local . redmine-5.0-stable$ cp -p ../redmine-4.2-stable/config.ru . redmine-5.0-stable$
Redmine 4.2 のディレクトリ下からプラグインをRedmine 5.0のディレクトリへコピー
まず、Redmine 4.2のディレクトリ下からプラグインをコピーします。
lib$ cd redmine-5.0-stable redmine-5.0-stable$ cp -pr ../redmine-4.2-stable/plugins/* plugins/ redmine-5.0-stable$ ls plugins/ README redmine_glossary redmine_wiki_lists google_analytics_plugin redmine_issue_templates redmine_xls_export redmine_banner redmine_latex_mathjax sidebar_hide redmine_cozy_wiki_macros redmine_theme_changer view_customize redmine_github_hook redmine_wiki_extensions redmine-5.0-stable$
各プラグインのディレクトリで git pull 等を実行して最新にします。
また、各プラグインがRedmine 5.0に対応しているかどうか配布元サイト等を確認しておきます。 (2022年4月24日調べ)
No. | Plugin name | Redmine 5.0対応 | zeitwerk:check結果 | 最新版状況 | 備考 |
---|---|---|---|---|---|
1 | google_analytics_plugin | 未記載 | 否 | 最新版v1.0.1は2020年 | |
2 | redmine_banner | 未記載 | 否 | 最新版v0.3.4は2020年7月 | agileware-jpフォーク版が対応 |
3 | redmine_cozy_wiki_macros | 未記載 | 良 | 最新版v0.3.1は2019年12月 | |
4 | redmine_github_hook | 未記載 | 否 | 最新版v3.0.1は2019年7月 | |
5 | redmine_glossary | 未記載 | 良 | 最新版v1.1.0は2020年1月 | |
6 | redmine_issue_template | 未記載 | 否 | 最新版v1.1.0は2020年8月 | agileware-jpフォーク版が対応 |
7 | redmine_latex_jathjax | 未記載 | 良 | 最新版は2020年4月 | |
8 | redmine_theme_changer | 対応済み | 良 | 対応版 v0.5.0 | |
9 | redmine_wiki_extensions | 対応済み | 良 | 対応版 v0.9.3 | |
10 | redmine_wiki_lists | 未記載 | 良 | 最新版は2021年4月 | |
11 | redmine_xls_export | 未記載 | 否 | 最新版v0.2.1.t11は2018年12月 | |
12 | sidebar_hide | 未記載 | 否 | 最新版v0.0.8は2017年1月 | |
13 | view_customize | 未記載 | 良 | 最新版v3.0.1は2022年1月 |
Redmine 4.2のディレクトリからテーマファイルをRedmine 5.0のディレクトリへコピー
redmine-5.0-stable$ ls public/themes/ README alternate classic redmine-5.0-stable$ rsync -av --exclude alternate --exclude classic ../redmine-4.2-stable/public/themes/ public/themes/ redmine-5.0-stable$
各テーマ(alternateとclassicを除く)のディレクトリで git pull 等を実行して最新にします。
Redmine 5.0のディレクトリで必要なgemsをインストール
redmine-5.0-stable$ bundle install --path vendor/bundler --without development test : Bundle complete! 50 Gemfile dependencies, 85 gems now installed. :
Redmine 5.0 のディレクトリで、5.0に非対応なプラグインをチェック
zeitwerk オートロードに対応しているかどうかをチェックします。エラーが発生するとそこでとまるようなので、非対応なプラグインを検知したらそのプラグインのディレクトリを削除して、という作業を繰り返します。
redmine-5.0-stable$ bundle exec rake zeitwerk:check RAILS_ENV=production rake aborted! LoadError: cannot load such file -- google_analytics_hooks : redmine-5.0-stable$ rm -rf plugins/google_analytics_plugin/
redmine-5.0-stable$ bundle exec rake zeitwerk:check RAILS_ENV=production rake aborted! LoadError: cannot load such file -- banners/application_hooks : redmine-5.0-stable$ rm -rf plugins/redmine_banner/
redmine-5.0-stable$ bundle exec rake zeitwerk:check RAILS_ENV=production rake aborted! LoadError: cannot load such file -- issue_templates/issues_hook : redmine-5.0-stable$ rm -rf plugins/redmine_issue_templates
redmine-5.0-stable$ bundle exec rake zeitwerk:check RAILS_ENV=production rake aborted! LoadError: cannot load such file -- xlse_asset_helpers : redmine-5.0-stable$ rm -rf plugins/redmine_xls_export/
redmine-5.0-stable$ bundle exec rake zeitwerk:check RAILS_ENV=production rake aborted! LoadError: cannot load such file -- sidebar_hook_listener : redmine-5.0-stable$ rm -rf plugins/sidebar_hide/
redmine-5.0-stable$ bundle exec rake zeitwerk:check RAILS_ENV=production Hold on, I am eager loading the application. rake aborted! NameError: uninitialized constant RedmineGithubHook::Version Did you mean? RedmineGithubHook::VERSION : redmine-5.0-stable$ rm -rf plugins/redmine_github_hook/
redmine-5.0-stable$ bundle exec rake zeitwerk:check RAILS_ENV=production Hold on, I am eager loading the application. All is good!
この段階で、けっこう厳しい状況が分かりました。 banner、issue_template、github_hook、は使いたいので、もうちょっとRedmine 5.0対応は待った方がよさそうです。
ということで、次の作業は中断とし、しばらく様子見をすることにしました。
bannerとissue_templateは、フォーク版で対応していることが分かりました。以降に処置を記述しました。 github_hookは作者がRedmineを使わなくなったので後継者を募集中です。そのため処置が遅れそうです。また、フォーク版をざっと探しましたが対応しているものが見つからずでした。
非対応なプラグインの処置
google_analytics_plugin
Redmine 4.2のディレクトリでアンインストールします。
~$ cd /var/lib/redmine-4.2-stable redmine-4.2-stable$ bundle exec rake redmine:plugins:migrate NAME=google_analytics_plugin VERSION=0 RAILS_ENV=production
redmine_banner
フォーク版が対応しているので、フォーク版をclone
redmine-5.0-stable$ cd plugins plugins$ git clone https://github.com/agileware-jp/redmine_banner.git :
データベースの変更はないので、ディレクトリを削除しcloneすればOKのはず。
redmine_issute_template
フォーク版が対応しているので、フォーク版をclone
plugins$ git clone https://github.com/agileware-jp/redmine_issue_templates.git :
redmine_github_hook
Redmine 4.2のディレクトリでアンインストールします。
~$ cd /var/lib/redmine-4.2-stable redmine-4.2-stable$ bundle exec rake redmine:plugins:migrate NAME=redmine_github_hook VERSION=0 RAILS_ENV=production
redmine_xls_export
Redmine 4.2のディレクトリでアンインストールします。
~$ cd /var/lib/redmine-4.2-stable redmine-4.2-stable$ bundle exec rake redmine:plugins:migrate NAME=redmine_xls_export VERSION=0 RAILS_ENV=production
sidebar_hide
Redmine 4.2のディレクトリでアンインストールします。
~$ cd /var/lib/redmine-4.2-stable redmine-4.2-stable$ bundle exec rake redmine:plugins:migrate NAME=sidebar_hide VERSION=0 RAILS_ENV=production
Redmine 5.0のディレクトリでマイグレート実行
Redmine 本体のデータベースマイグレーション
redmine-5.0-stable$ bundle exec rails db:migrate RAILS_ENV=production == 20210704125704 AddTwofaRequiredToGroups: migrating ========================= -- add_column(:users, :twofa_required, :boolean, {:default=>false}) -> 0.0113s : == 20220224194639 DeleteOrphanedTimeEntryActivities: migrating ================ == 20220224194639 DeleteOrphanedTimeEntryActivities: migrated (0.0382s) ======== redmine-5.0-stable$
プラグインのマイグレーション
redmine-5.0-stable$ bundle exec rails redmine:plugins:migrate RAILS_ENV=production redmine-5.0-stable$
特に更新なし
Redmine 4.2のディレクトリから添付ファイルをRedmine 5.0のディレクトリへコピー
redmine-5.0-stable$ rsync -a ../redmine-4.2-stable/files/ files redmine-5.0-stable$
セッション鍵の生成
redmine-5.0$ bundle exec rake generate_secret_token
Unicorn 設定ファイルの変更
/usr/lib/systemd/system/redmine-unicorn.service
- WorkingDirectory=/var/lib/redmine-4.2-stable + WorkingDirectory=/var/lib/redmine-5.0-stable - PIDFile=/var/lib/redmine-4.2-stable/tmp/pids/unicorn.pid + PIDFile=/var/lib/redmine-5.0-stable/tmp/pids/unicorn.pid
config/routes.rb
Rails.application.routes.draw do - root :to => 'welcome#index', :as => 'home' + root :to => 'wiki#show', :project_id => 'swe', :as => 'home'
Unicorn を再起動
~$ sudo systemctl restart redmine-unicorn.service