This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 他のプロジェクトのビルドを実行する方法 | |
// 以下は groovy plugin の Execute system Groovy script の中で使用して | |
// TEST プロジェクトのビルドを実行する例 | |
def jobname = "TEST" | |
hudson.model.Hudson.instance.getItem(jobname).scheduleBuild() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プラクティスとして良いかどうかは別として、他のプロジェクト固有の環境変数を得る方法 | |
// 以下は groovy plugin の Execute system Groovy script の中で使用して | |
// TEST プロジェクトの WORKSPACE 環境変数の情報を得る例 | |
def jobname = "TEST" | |
def envname = "WORKSPACE" | |
def job = hudson.model.Hudson.instance.getItem(jobname) | |
def envVars= job.lastBuild.properties.get("envVars") | |
println envVars[envname] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 1. depjobnameで指定したジョブよりも自分自身が先にキューに入った場合は、自分自身のビルドを即実行する。 | |
// 2. depjobnameで指定したジョブよりも自分自身が後にキューに入った場合は、depjobnameの終了を待つ。 | |
// 2-1. ポーリング方式で終了を待つ | |
// 2-2. 最大リトライ回数は retrycount で指定 | |
// 2-3. リトライ間隔は sleeptime で指定(単位はミリ秒) | |
// 3. depjobnameで指定したジョブが存在しなかった場合は、ビルドを失敗させるためにあえて例外が発生する | |
// ようにしています。 | |
// 4. 設定手順 | |
// 4-1. Groovy Pluginをインストールする |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Jenkinsのビルド中のジョブを取得する | |
def jobs = hudson.model.Hudson.instance.items.findAll { it.isBuilding() } | |
jobs.each { println it.name } |
NewerOlder