_Events.groovy
特定の状況下で、eventListener クロージャー内でビルドを失敗させたいと考えています。
私は2つのアプローチを試みました:
- 投げる
RuntimeException()
- 電話
ant.fail('failing the build')
両方のコンソールに次の出力が表示されます。
| Building WAR file.....
running event listener code...
[ERROR] Invalid environment argument of: 'tingaeuaeou', must be either 'testing', 'package', 'production' or 'native'
| Error Exception occurred trigger event [CreateWarStart]: Sencha SDK optimization failed. (Use --stacktrace to see the full trace)
| Done creating WAR target/product-selector-0.1.war
grails>
ビルドを失敗させるために書いたコードは次のとおりです。
...
ant.exec(outputproperty: "cmdOut", executable: 'sencha',
dir: "$stagingDir", failOnError: true) {
arg(value: 'app')
arg(value: 'build')
arg(value: "-e $senchaEnvironment")
}
def commandOutput = ant.project.properties.cmdOut
println "${commandOutput}"
if(commandOutput.contains('ERROR')){
ant.fail(message:"Sencha SDK optimization failed.",status:1)
}
...
問題は、war スクリプトが実行され続け、破損する war ファイルを生成することです。ビルド プロセスで例外が発生したとは報告されません。私の継続的インテグレーション ビルドは誤った成功を報告します!
何か案は?