Finding Job's UUID from BF step log
Hi,
I'm trying to figure out a way to correlate between BF_CALLER_BID parameter in a fail/pass chain and build UUID which can be used in java api code for Build.findByUuid for example.... How do I single out 1 specific build in java API using data from BF step log BF_CALLER_ vars? TIA AD |
2 answers
Hi, I'm not yet crystal clear on what you're trying to accomplish or which particular build you're searching for (in the long chain I assume you have). However, there are a few methods that come to mind to traverse the chaining hierarchy. First, you could start with your initial / 'root' build (if you know that), load it, and follow its pass or fail chain build (via the getChainedBuildUuid() method), loading that target build, then getting its chained build uuid, etc. until you find the specific build you had in mind. Second, since you mention environment variables (BF_CALLER_BID, specifically), you can also traverse the hierarchy that way. In general, BF_CALLER_BID will contain the immediate build that chained 'you'. If you want each build in the hierarchy to have a visible environment variable, you'll want to set the 'Stack BuildForge Env Variables' sysconfig (under Administration->System). This will add a 'CALLER_' string to mark each "level" of chaining. For example, given that 'stack env' is set, and given three builds that chain each other (parent, child, and grandchild), then here are the values : Parent : {No BF_CALLER since it's the 'root'} Child : BF_CALLER_BID = {uuid of Parent} GrandChild : BF_CALLER_BID = {uuid of Child} BF_CALLER_CALLER_BID = {uuid of Parent} -steve |
I'm trying to detect which build triggered the chain in a chain which was not triggered by API, I want to start a utility from fail chain which will detect that the parent failed and try to restart it.
This is what I ended up doing, because the default behavior is confusing - documentation says that when Stack is set to "N" it provides single level of variables, when in fact, you get multiple BF_CALLER_ variables which list details of multiple predecessors in no particular order. It seems enabling Stacking sorts it out. Thanks |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.