Jenkins: how can I get builds of follow-up work corresponding to creating multi-configuration parent jobs using the Jenkins API

I have jobs in jenkins in the 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

Tasks are called such that M calls B for each configuration. B completes the assembly and calls T to test the assembly and waits for it to complete. T calls TW and TL in parallel and waits for their result. If any downstream task fails, then this configuration in M ​​is marked as a failure. Similarly, B is flagged as failed if any T-job fails.

I use the Email Ext plugin to email the status of jobs B and T of all configurations at the end of M. The Email Ext plugin provides a build object corresponding to build on M. I cannot find any jenkins API that gives subsequent builds B, T, TL and TW caused by the construction of M.

I am currently 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 because someone might initiate a downstream build manually while the parent assembly is in progress. There must also be some way to directly obtain the assembly object of subsequent threads corresponding to the parent task. Can you suggest some way to solve this problem.

+4
source share

No one has answered this question yet.

Source: https://habr.com/ru/post/1621294/


All Articles