LoginSignup
8
10

More than 5 years have passed since last update.

jenkinsでCakePHPのテスト、の設定

Last updated at Posted at 2014-12-26

設定前半

  1. プロジェクト名を入れる

  2. 古いビルドの破棄にチェック

  3. Log Rotation を選んで保存日数を30日に

  4. ソースコード管理でGitを選択
    Repository URL にはアルミニウムのリポジトリのパスを入れる。
    例)/var/opt/alminium/git/myproject

  5. ブランチのところは */develop かな・・。

  6. ビルドトリガは「定期的に実行」でスケジュールが
    H 1 * * 1-5

ビルド設定

まず、ソナー

cd ${WORKSPACE}
/usr/local/bin/sonar-runner-2.3/bin/sonar-runner

リポジトリからパス ${WORKSPACE} に展開される。
例)/var/lib/jenkins/jobs/PHP/workspace
直下にsonar-project.propertiesが置かれている。その場所でsonar-runnerを走らせる、という意味。
つまりソナーランナーもあらかじめこのサーバーにインストールしてある

次、コードスニッファー

cd ${WORKSPACE} && /usr/bin/phpcs --report=checkstyle --report-checkstyle=${WORKSPACE}/reports/checkstyle.xml --standard=CakePHP \
--extensions=php --ignore=app/Vendor/*,app/Test/*,app/Plugin/*,app/Config/* ./app || id

workspace直下のreportsというディレクトリ内にcheckstyle.xmlという結果のファイルを出力せよ、という意味。
つまりworkspace直下にreportsというディレクトリをあらかじめ作っておく。
これもあらかじめphpcsがサーバーにインストールしてあるイメージ。

phpunitの実施

cd ${WORKSPACE}/app && Console/cake test app All \
--stderr \
--log-junit ${WORKSPACE}/reports/junit.xml \
--coverage-html ${WORKSPACE}/reports/clover_html/ \
--coverage-clover ${WORKSPACE}/reports/clover.xml

こちらも結果をreports以下に出力している。
Console/cake test app All ここはcakeのコマンドそのまま。DB接続がなくても動くのかどうかは不明。

ビルド後の処理

  1. 「Checkstyle警告の集計」を選んで設定。
    ファイルで上記のreports/checkstyle.xmlを設定。workspaceからの相対パスでいい

  2. 同じくCloverPHPカバレッジレポート集計reports/clover.xml
    CloverHTMLレポートを公開するにチェック
    reports/clover_html/
    JUnitテスト結果の集計にreports/junit.xml

8
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10