A man who fired a gun at a group of people before fleeing has been jailed.