The barrel is thicker than the armor on tanks. Usually they weigh in at over 2 tons of steel. The circular shape also makes it very likely to deflect the impact like sloped armor.
Bullets are deflected along surprisingly sharp bends in a barrel (or any other pipe), so it would be sufficient to hit the tank gun muzzle roughly from the front, and it would probably hit a loaded projectile.
Technically, it would be sufficient of they lodge a bullet into the barrel. As soon as the tank fires, the bullet will wedge between the shell and the barrel, destroying - at least - the barrel.