According to Brewer's Dictionary of Phrase and Fable it is a phrase of uncertain origin. It goes on
"A popular explanation is that it was a British soldiers' or sailors' rendering of "O mihi beate Martine", an invocation to St. Martin heard abroad.
All my eye is the older saying:
"That's all my eye, the King only can pardon, as the law says." ( Oliver Goldsmith - "The Good Natur'd Man" - 1767 )