public static AbstractBuild < ? , ? > getRootBuild ( AbstractBuild < ? , ? > currentBuild ) { AbstractBuild < ? , ? > rootBuild = null ; AbstractBuild < ? , ? > parentBuild = getUpstreamBuild ( currentBuild ) ; while ( parentBuild != null ) { if ( isPassIdentifiedDownstream ( parentBuild ) ) { rootBuild = parentBuild ; } parentBuild = getUpstreamBuild ( parentBuild ) ; } if ( rootBuild == null && isPassIdentifiedDownstream ( currentBuild ) ) { return currentBuild ; } return rootBuild ; }
Get the root build which triggered the current build . The build root is considered to be the one furthest one away from the current build which has the isPassIdentifiedDownstream active if no parent build exists check that the current build needs an upstream identifier if it does return it .