DependencyGraph: Get Ordered Transitive Dependencies

8 views
Skip to first unread message

Sverre Moe

unread,
Jan 13, 2022, 5:56:28 AM1/13/22
to Jenkins Users
We are using Jenkins Pipelines, but need to maintain build dependencies.

Since DependencyGraph does not work on Pipeline jobs, I have created a set of FreeStyle jobs for each Multibranch Pipeline job.

We get the upstream dependencies for each Pipeline job (from the RPM spec file BuildRequires), and populate them in the corresponding FreeStyle job.

Then I can call the FreeStyle job getTransitiveDownstreamProjects(), to get the list of direct and indirect build dependencies.

However I noticed that this is not ordered. The list seems to be in alphabetical order.
Example: ProjectA has ProjectB and ProjectC as downstream dependencies.
But getTransitiveDownstreamProjects puts ProjectA at the bottom of the list, and not before ProjectB and ProjectC.

Is there any way to get the transitive dependencies in an ordered list?
Showing the Dependency Graph View, I can clearly see that ProjectA is on a level above ProjectB and ProjectC.

Since Dependency Graph View shows the dependencies ordered, it should be possible to get that order in a list. Unless DependencyGraph does not have an API for that.

I am using FreeStyleJob and DependencyGraph, since DependencyGraph already have the structure and algorithms to calculate upstream and downstream dependencies.
I really wish Pipelines could support DependencyGraph, but if DependencyGraph cannot get me an ordered list, I think we would need to implement something similar to DependencyGraph our self in a shared pipeline script. The advantage of FreeStyle and DependencyGraph is you can persist those dependencies to disk.

Reply all
Reply to author
Forward
0 new messages