I have jobs on Jenkins in following hierarchy
M -> B -> T -> TW
-> TL
M = multi-configuration master job
B = single configuration build job
T = testing parent job
TW = testing job for Windows
TL = testing job for Linux
The jobs are called such that M calls B for each configuration. B completes the build and calls T for testing the build and waits for it to complete. T calls TW and TL in parallel and waits for their result. If any downstream job fails then that configuration in M is marked as failure. Similarly, B is marked fail if any T job fails.
I am using Email Ext plugin to email the status of B and T jobs of all the configurations at the end of M. The Email Ext plugin gives a build object corresponding to build on M. I am unable to find any jenkins API which gives downstream builds of B, T, TL and TW called by the build of M.
Currently I am doing this:
- Get the project object of M from build object.
- Get downstream project (project B)
- Get latest build of B
- Traverse through builds using getPreviousBuild
Check if the build was triggered after the parent build
to know if this build corresponds to our parent job build
Check the build parameters to determine config of parent job
This approach is fragile as someone can trigger a downstream build manually while the parent build is running. Also there should be some way to directly get the build object of downstream builds corresponding to parent job build. Can you please suggest some way to solve this issue.