A former British soldier, who spied for Iran during his time in the army, has been jailed for 14 years and three months.