timja / jenkins-gh-issues-poc-06-18

0 stars 0 forks source link

[JENKINS-27527] Jenkins API: Set upstream and downstream projects #5991

Open timja opened 9 years ago

timja commented 9 years ago

Set a projects upstream or downstream projects with Jenkins API.

AbstractProject.addUpstreamProject(AbstractProject)
AbstractProject.setUpstreamProjects(List)

AbstractProject.addDownstreamProject(AbstractProject)
AbstractProject.setDownstreamProjects(List)

Setting upstream projects is not possible without creating a build trigger.


Originally reported by djviking, imported from: Jenkins API: Set upstream and downstream projects
  • status: Open
  • priority: Minor
  • resolution: Unresolved
  • imported: 2022/01/10
timja commented 9 years ago

djviking:

Perhaps I am doing it wrong, but a projects upstream and downstream projects does not get set when adding a trigger

import jenkins.triggers.ReverseBuildTrigger
import hudson.model.Result

def jenkinsInstance = jenkins.model.Jenkins.getInstance()
def project = jenkinsInstance.getItem("myLib2")

def trigger = new ReverseBuildTrigger("myLib1", Result.SUCCESS)
project.addTrigger(trigger)
project.getUpstreamProjects().size() == 0
project.getDownstreamProjects().size() == 0
timja commented 9 years ago

danielbeck:

It's asynchronous so it could take a bit to set the relation.

timja commented 9 years ago

djviking:

It took over 20 minutes for the upstream project to appear on the project main page.

Still, I created this issue because it would be great if one could set the upstream and downstream projects with the API, but it only has getters for them.

timja commented 9 years ago

danielbeck:

This isn't how the API works. Check out how hudson.model.DependencyGraph works.