2011-02-28
JenkinsでJOJO名言を表示する
Jenkins | |
仕組みは、「Ajax - スクリプトコンソール - fortuneコマンド」です。fortuneというコマンドを使っているのでWindowsではできないかもしれません。もしかするとCygwinでできるかもしれません。
1. fortuneコマンドをJenkinsサーバにインストール
私はMacを使っているのでMacPortsでの例になりますが、yumとかapt-getでも同じ要領です。
$ sudo port install fortune
fortuneコマンドで色々な格言が表示されます。
$ fortune Anything cut to length will be too short.
2. JOJO名言を用意する
DATファイルを用意しておけばfortuneコマンドで表示される格言を追加できます。以下のサイトを参考にファイルを作成しました。
- fortuneのファイルの作り方 - Practice of Programming
- ジョジョの奇妙なGreasemonkey - AUSGANG SOFT (スクリプト内の名言をパクらせてもらいました。)
上記サイトを参考に、jojoとjojo.datファイルを作成して /opt/local/share/games/fortune ディレクトリに格納するとfortuneコマンドに引数でJOJO名言が出力されます。
$ fortune jojo 「だが断る」(41巻)
3. Jenkins「説明を記入」
Jenkinsの「説明を記入」のところに以下のようなJavaScriptを書きます。
<pre id="fortune" style="font-size: 14px" with="100%"></pre> <script> (function() { function fortune() { new Ajax.Request(rootURL + '/script', { method: 'post', postBody: 'script='+encodeURIComponent("'fortune jojo'.execute().with{waitFor();println text}"), onSuccess: function(xhr) { var tmp = document.createElement('div') tmp.innerHTML = xhr.responseText document.getElementById('fortune').textContent = tmp.getElementsByTagName('pre')[1].textContent } }) } fortune() setInterval(fortune, 5000) })() </script>
これでJenkins画面上にJOJO名言が5秒おきに表示されます。

リンク元
- 127 http://pipes.yahoo.com/pipes/pipe.info?_id=tDfBdGWF3RGl9XNm1L3fcQ
- 11 http://wiki.jenkins-ci.org/pages/viewpage.action?pageId=54723198
- 10 http://discypus.jp/wiki/?ソフト/Bug Tracking/trac/2011
- 9 http://longurl.org
- 8 http://twitter.com/
- 7 http://pipes.yahoo.com/pipes/pipe.info?_id=12e453e301454b799b3ac6642aa089b5
- 7 http://reader.livedoor.com/reader/
- 6 http://htn.to/gNYYUQ
- 5 http://d.hatena.ne.jp/ksky/20110301/p1
- 4 http://www.google.co.jp/reader/view/
