CruiseControl:設定編


 手引き*1を読み飛ばしながら進めるだけ。英語?・・・フィーリングだ!


・Install CruiseControl

 インストールできているかの確認

D:\applications\cruisecontrol-2.2.1\main\dist>java -jar ./cruisecontrol.jar
[cc]5-16 11:32:24 Main - CruiseControl Version 2.2.1
[cc]5-16 11:32:24 Main - Config file not found: config.xml
[cc]5-16 11:32:24 Main - Usage:
[cc]5-16 11:32:24 Main -
[cc]5-16 11:32:24 Main - Starts a continuous integration loop
[cc]5-16 11:32:24 Main -
[cc]5-16 11:32:24 Main - java CruiseControl [options]
[cc]5-16 11:32:24 Main - where options (all optional) are:
[cc]5-16 11:32:24 Main -
[cc]5-16 11:32:24 Main - -port [number] where number is the port of the Controllerweb site; defaults to 8000
[cc]5-16 11:32:24 Main - -rmiport [number] where number is the RMI port of the Controller; defaults to 1099
[cc]5-16 11:32:24 Main - -xslpath directory where directory is location of jmx xsl files; defaults to files in package
[cc]5-16 11:32:24 Main - -configfile file where file is the configuration file; defaults to config.xml in the current directory
[cc]5-16 11:32:24 Main - -debug to set the internal logging level to DEBUG
[cc]5-16 11:32:24 Main -
[cc]5-16 11:32:24 Main - Please keep in mind that the JMX server will only be started if you specify -port and/or -rmiport


 まだconfigを作成していないが、とりあえずは確認できたということらしい。


・Running the Build Loop

 ここでは"作業ディレクトリ"と"configファイル"を作成する。

 インストールしたディレクトリとは分けろ、ということなので"D:\work\cruise"(以下"WORK_DIR")を作成。
 その下にさらにサブディレクトリを作成。

 artifacts :結果をJSP化したものを保管する(らしい)
 checkout :CVSからチェックアウトしてきたものを入れる
 logs   :そのまんま


 手引きに従って(ちょっと進化した)、CruiseControlの設定ファイルをWORK_DIRに作成して、CruiseControlをbatから起動させてみる。

D:\applications\cruisecontrol-2.2.1\main\bin>cruisecontrol.bat -configfile D:\work\cruise\config.xml

(なにやらパスがでてくるのは略、以下同)
[cc]5-16 13:12:47 Main - CruiseControl Version 2.2.1
[cc]5-16 13:12:48 BuildQueue - BuildQueue started


 設定ファイルの中身がないのでここで止まってしまうのは手引きの通り。
 とりあえずサンプルをプロジェクトの名前だけ変更して使ってみる。

 1回目のループ

[cc]5-16 15:34:27 Main - CruiseControl Version 2.2.1
[cc]5-16 15:34:28 trolController- projectName = [Test1]
[cc]5-16 15:34:28 trolController- No previously serialized project found: D:\work\cruise\Test1
[cc]5-16 15:34:28 Project - Project Test1: reading settings from config file [D:\work\cruise\config.xml]
[cc]5-16 15:34:28 Project - Project Test1 starting
[cc]5-16 15:34:28 Project - Project Test1: idle
[cc]5-16 15:34:28 BuildQueue - BuildQueue started
[cc]5-16 15:34:28 Project - Project Test1 started
[cc]5-16 15:34:28 Project - Project Test1: next build in 10 seconds
[cc]5-16 15:34:28 Project - Project Test1: waiting for next time to build

 ※" No previously〜"とでているのは、カレントにTest1.serが作成されると?次回からはでない


 2回目のループ

[cc]5-16 15:34:38 Project - Project Test1: in build queue
[cc]5-16 15:34:38 BuildQueue - now adding to the thread queue: Test1
[cc]5-16 15:34:38 Project - Project Test1: reading settings from config file [D:\work\cruise\config.xml]
[cc]5-16 15:34:38 Project - Project Test1: bootstrapping
[cc]5-16 15:34:38 Project - Project Test1: checking for modifications
[cc]5-16 15:34:39 Project - Project Test1: No modifications found, build not necessary.
[cc]5-16 15:34:39 Project - Project Test1: Building anyway, since build was explicitly forced.
[cc]5-16 15:34:39 Project - Project Test1: now building
Buildfile: build-Test1.xml
[cc]5-16 15:34:40 Project - Project Test1: merging accumulated log files
[cc]5-16 15:34:40 Project - Project Test1: build successful
[cc]5-16 15:34:40 Project - Project Test1: publishing build results
[cc]5-16 15:34:40 Project - Project Test1: idle
[cc]5-16 15:34:40 Project - Project Test1: next build in 10 seconds
[cc]5-16 15:34:40 Project - Project Test1: waiting for next time to build

 buildファイルがコールされたらしい。"logs/Test1"に"log20050516153438Lbuild.1.xml"が作成されている。


 3回目のループ

[cc]5-16 15:34:50 Project - Project Test1: in build queue
[cc]5-16 15:34:50 BuildQueue - now adding to the thread queue: Test1
[cc]5-16 15:34:50 Project - Project Test1: reading settings from config file [D:\work\cruise\config.xml]
[cc]5-16 15:34:50 Project - Project Test1: bootstrapping
[cc]5-16 15:34:50 Project - Project Test1: checking for modifications
[cc]5-16 15:34:51 Project - Project Test1: No modifications found, build not necessary.
[cc]5-16 15:34:51 Project - Project Test1: idle
[cc]5-16 15:34:51 Project - Project Test1: next build in 10 seconds
[cc]5-16 15:34:51 Project - Project Test1: waiting for next time to build

 変更がないので何も実行されないらしい。

 ここまで実行して気がついたが、別にCruiseControl自身がテストをしてくれるわけではなく、必要なとき(更新があったとき?)にantからテストを実行し、その結果をメール配信なりWebサーバへコピーなりしてくれるらしい・・・としっかりと本に書いてあった!


 さて、"modifications"が検出される条件だが、マニュアル*2を読めば何やら前回のビルドした時間と比較するようなのだが、CVSにソースをコミットしても「変更なし」を連発されてしまう


 うーん・・・悩むぐらいなら「毎回実行」にしよう。

  
   
  


 しばし待つ(config.xmlを更新しても、CruiseControlを再起動する必要はない)

[cc]5-16 16:16:36 Project - Project Test1: in build queue
[cc]5-16 16:16:36 BuildQueue - now adding to the thread queue: Test1
[cc]5-16 16:16:36 Project - Project Test1: reading settings from config file [D:\work\cruise\config.xml]
[cc]5-16 16:16:36 Project - Project Test1: bootstrapping
[cc]5-16 16:16:36 Project - Project Test1: checking for modifications
[cc]5-16 16:16:36 odificationSet- 1 modification has been detected.
[cc]5-16 16:16:36 Project - Project Test1: now building
Buildfile: build-Test1.xml
[cc]5-16 16:16:41 Project - Project Test1: merging accumulated log files
[cc]5-16 16:16:41 Project - Project Test1: build successful
[cc]5-16 16:16:41 Project - Project Test1: publishing build results
[cc]5-16 16:16:41 Project - Project Test1: idle
[cc]5-16 16:16:41 Project - Project Test1: next build in 10 seconds
[cc]5-16 16:16:41 Project - Project Test1: waiting for next time to build


 しかし今度は毎回"1 modification has been detected."がでるなぁ。強制的に出しているのかな。


 ビルド結果の通知はメールで行う。
 以下の記述(手引きをちょっと直しただけ)をの中に記述する。


     

 こうしておけば失敗したときだけ通知される。
 届いたメール

View results here -> http://localhost/cc/buildresults/Test1?log=log20050516153254Lbuild.1

 ということは、の中でantをコールして、ログファイルをwebサーバの下に置かないとだめだね。
 cruisecontrolのアプリをTomcatの下に配備する。で、そのアプリのweb.xmlにログディレクトリのパスを記述するのだ。



 ここまでで解決したこと

・特定の間隔で(強制的に)antを実行させる
・レポートをメール配信する


 もうちょっと考えること

・緊急にビルドをして、そのテスト結果も確認したいときとかはどうすればいいんだろう???
 =>別プロセスで一度CruiseControlを起動すると、ストップさせるのを忘れたときが悲しい。

 一度起動したCruiseControlをその度に再起動するのもあれだしなぁ。