Measurement of the $\Upsilon$(nS) polarizations in pp collisions at $\sqrt{s}$ = 7 and 8 TeV