A man who blew up three cash machines with homemade bombs in a failed attempt to steal thousands of pounds has been jailed for eight years.