Hierarchical black hole mergers in young, globular and nuclear star clusters: the effect of metallicity, spin and cluster properties