How to get the build ID(s) of predecessor jobs in a pipeline

Hi folks,

I’m new to the community and to Jenkins so please go easy on me.

On my team, we have a pipeline that basically runs two jobs (Cucumber tests) in parallel and then runs a consolidator job at the end to consolidate the reports from the previous two jobs.

The consolidator is somewhat rudimentary today. It just gathers the most recent logs from a recent build folder name that matches some parameters (environment, suite, etc.). The issue is that the consolidator might accidentally pick up results from a build that was not actually scheduled by the pipeline that ran it. That caused a lot of confusion and poses a risk for us because, at any given time, we might be looking at the wrong results.

I would like to augment the consolidator to use the actual build IDs of the two preceding parallel jobs as extra salt in the folder names for storing and subsequently finding/consolidating the results. That should guarantee that the problem above doesn’t happen again.

The consolidator is a bash script. I’m afraid I don’t have it in front of me because I’m at home and can’t remotely log in. I also don’t have other information like Jenkins version or plugins etc. Sorry.

Is there a way for a job to find out what the preceding job IDs were in the pipeline that ran it?

Thanks!