The provisions of the real property actions and proceedings law relating to actions for the foreclosure of a mortgage upon real property, and the sale and the distribution of the proceeds thereof apply to actions in a court of record, to enforce mechanics’ liens on real property, except as otherwise provided in this article. If actions are brought by different lienors in a court of record, the court in which the first action was brought, may, upon its own motion, or upon the application of any party in any of such actions, consolidate all of such actions.