The phrase "Close, but no cigar" is popular with sports commentators the world over, for example in golf for missed putts. It is also in general usage. For example in the workplace, I have come across it, or the shortened form "No cigar" used to describe incomplete bugfixes and missed project deadlines.

The origin of this phrase is in the States in the 1800s and early 1900s, where cigars were given as fairground prizes.

There is an important cultural difference between the image of smoking cigars in Britain, and in America. In Britain, cigars were portrayed as symbolising luxury, having been brought back across the Atlantic by Sir Walter Raleigh. Later, British governments imposed huge excise duty on tobacco and tobacco products, again restricting cigars to the rich, and reinforcing the image of opulence.

In America, on the other hand, where the cigars were actually made, they were sold on a door to door basis. In fact, cigars were more popular in the States than cigarettes until the 1950s.

Source:   Alistair Cooke's Letter From America: