以前、Groovy post build プラグインから IRC Plugin の機能を呼び出して、任意のメッセージを飛ばすことをやりましたが、これを Jenkinsfile に記述します。
やり方は単純
Jenkinsfile にそのまま書くだけです。以前、Groovy Label Assignment plugin 向けに書いた groovy がこちら。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def jenkins = hudson.model.Hudson.instance def irc_channel= "#kiwiirc-iutest" def p = jenkins.getPlugin( "ircbot" ) if ( p == null ) { println ( "require IRC Plugin" ) return } def c = p.imPlugin.provider.currentConnection() if ( c == null ) { println ( "IRC connection not found. please set to IRC configuration" ) return } c.send(irc_channel, "label assignment" ) return |
これを、すこし汎用的にして Jenkins ファイルに追加します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
def send_irc(channel, message) { def jenkins = hudson.model.Hudson.instance def p = jenkins.getPlugin( "ircbot" ) if ( p == null ) { println ( "require IRC Plugin" ) return } def c = p.imPlugin.provider.currentConnection() if ( c == null ) { println ( "IRC connection not found. please set to IRC configuration" ) return } c.send(channel, message) return } |
で、あとはお好きなタイミングで呼び出すだけです。
1 2 3 |
stage( 'irc-send' ) { send_irc( '#TEST' , 'ビルドに成功したよ!' ) } |
簡単ですね^^
0 件のコメント:
コメントを投稿