Skip to content

Instantly share code, notes, and snippets.

@tyuki39
Created March 8, 2011 15:48
Show Gist options
  • Save tyuki39/860427 to your computer and use it in GitHub Desktop.
Save tyuki39/860427 to your computer and use it in GitHub Desktop.
Jenkinsで下流ビルドと上流ビルドを取得する方法
// あるプロジェクトの下流ビルドと上流ビルドを取得する方法
// 以下は groovy plugin の Execute system Groovy script の中で使用して
// TEST プロジェクトの下流ビルドと上流ビルドを取得する例
def jobname = "TEST"
def job = hudson.model.Hudson.instance.getItem(jobname)
def dep = hudson.model.Hudson.instance.dependencyGraph
assert job, "ERROR: Can't find the job $jobname."
assert dep, "ERROR: Can't get the dependency graph."
def downjobs = dep.getDownstream(job)
def upjobs = dep.getUpstream(job)
println downjobs.name
println upjobs.name
@tyuki39
Copy link
Author

tyuki39 commented Mar 9, 2011

Thank you for making my code simpler.

@tyuki39
Copy link
Author

tyuki39 commented Mar 9, 2011

I have found a simpler way to get downstream & upstream jobs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment