I would like to copy a FreeStyleProject to a new job and then set a new upstreamproject to this new job using groovy. I can't find any method on Class FreeStyleProject that let me do that: set a new upstreamproject. Is there some other method or trick that can accomplish this?
def x = "testproj"
def hi=hi.getItem(x)
hi.copy(x, "Copy"+x);
def newjob=hi.getItem("Copy"+x)
//newjob.setUpstreamProject("bar") //<<--?
def di = newjob.getUpstreamProjects()
for ( y in di ) {
println(y.name)
}
Update: For clarification:
Job A ====> Job B (A is upstream)
I want to copy Both jobs so i get i
Job A' and Job B' and then set A' or B' so I get A' =====> Job B' (A' is upstream)
I think I need to remove a build trigger and create a new build trigger (that is what creates the upstream/downstream concept it seems)