JenkinsでPlay Frameworkのプロジェクトを扱う


少し前からJenkinsを導入しています。
Playを使ったアプリケーションがあったので、Jenkinsにビルドの設定をしたときのメモ書きです。

前提条件:
Jenkinsはyumでインストール&設定済み

手順サマリ:
1. JenkinsサーバーにPlayのダウンロード
2. Playframework-plugin、Jenkins Cobertura pluginのインストールとパスの設定
3. Coberturaモジュールのインストール
4. プロジェクトの設定
5. ビルドの実行
6. テスト結果の表示

1. JenkinsサーバーにPlayのダウンロード
wgetを使って、もしくは別マシンにダウンロード済みであればscp等でPlay Frameworkをアップロードしておく
場所はjenkinsのホームフォルダのしたあたりに適当にあればよいと思われる。
/var/lib/jenkins/play/play-1.2.4

2. Playframework-plugin、Jenkins Cobertura pluginのインストールとパスの設定
JenkinsのメニューでJenkins->Jenkinsの管理->プラグインの管理->利用可能

□playframework-plugin
Hudson plugin for Play! framework.
It enables hudson to run play command and to generate test-result view per build looks like calimoucho.

□Jenkins Cobertura Plugin
This plugin integrates Cobertura coverage reports to Jenkins

上のプラグインをチェックしてインストールする

JenkinsのメニューでJenkins->Jenkinsの管理->システムの設定
Play pathという項目に先ほどダウンロードしたPlayの実行ファイルのパスを指定する
/var/lib/jenkins/play/play-1.2.4/play

3. Coberturaモジュールのインストール
下記コマンドを実行

$ /var/lib/jenkins/play/play-1.2.4/play install cobertura
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.2.4, http://www.playframework.org
~
~ Will install cobertura-2.4
~ This module is compatible with: 1.2.3
~ Do you want to install this version (y/n)? y
~ Installing module cobertura-2.4...
~
~ Fetching http://www.playframework.org/modules/cobertura-2.4.zip
~ [--------------------------100%-------------------------] 2400.0 KiB/s
~ Unzipping...
~
~ Module cobertura-2.4 is installed!
~ You can now use it by adding it to the dependencies.yml file:
~
~ require:
~     play -> cobertura 2.4
~

アプリケーションのconf/dependencies.ymlを編集

# Application dependencies

require:
    - play -> cobertura 2.4

4. プロジェクトの設定

  • Play! application pathはチェックをいれなくてOK
  • GitレポジトリのURL設定
  • ビルドで「ビルド手順の追加」をクリックして「Play!」を選択。Play commandというコマンドを入力する行が5行ほど現れるので、次の2つを入力「dependencies --sync」、「auto-test」
  • Coberturaカバレッジレポートの集計にチェックする。レポートパターンにCoberturaのXMLファイルのパスを指定する「test-result/code-coverage/coverage.xml」あとはデフォルト
  • Play! auto-test reportsにチェックをいれる

5. ビルドの実行
6. テストが通っていればレポートも出力される

参考URL:
http://d.hatena.ne.jp/Ehren/20110816/1313510736
http://www.slideshare.net/ikeike443/jenkinsplayci-7058604
http://www.playframework.org/modules/cobertura-2.4/home