Set upstream projects with the Jenkins API

72 views
Skip to first unread message

Sverre Moe

unread,
Mar 9, 2015, 7:02:05 AM3/9/15
to jenkin...@googlegroups.com
Using the Jenkins API I am trying to find a way to set the upstream projects for a given job/project.

From the API Javadocs http://javadoc.jenkins-ci.org/?hudson/model/AbstractProject.html I can only find getters for this:
getUpstreamProjects()
getTransitiveUpstreamProjects()

Is there any way using the API I could set upstream projects? 

I do not want to create a build trigger with upstream projects, because I do not want to build transitive upstream projects. I will instead use Groovy to iterate the upstream projects and schedule a build for each of them.

My last resort would be to add upstream projects directly as XML to config.xml

This is what I could find in config.xml
  <triggers>
    <jenkins.triggers.ReverseBuildTrigger>
      <spec></spec>
      <upstreamProjects>myLib++</upstreamProjects>
      <threshold>
        <name>SUCCESS</name>
        <ordinal>0</ordinal>
        <color>BLUE</color>
        <completeBuild>true</completeBuild>
      </threshold>
    </jenkins.triggers.ReverseBuildTrigger>
  </triggers>

This is what I could find in
<upstreamProject>
<name>myLib++</name>
<color>blue</color>
</upstreamProject>

Could not find any configuration in config.xml for upstream projects without a build trigger.
Reply all
Reply to author
Forward
0 new messages