Police found cannabis hidden behind the headlamp panel inside a car after they went to speak to a driver who was already on bail for a drugs offence.
Leeds Crown Court heard Akib Hussain was first arrested on January 2 last year after officers on duty in Primrose Hill saw a man approach two men inside a Renault Clio car and an apparent drug deal take place.
They followed when the vehicle then moved to the Tesco car park in the town centre and watched as another man approached the vehicle and left seconds later.
Richard Walters prosecuting said the car was then stopped. Hussain was in the front passenger seat and was found to have a lock knife in the waistband of his track suit bottoms.
Two mobile phones and £75 in cash were seized as well as a plastic bag containing 45 smaller grip seal bags containing cannabis with a street value of £455.
He was on police bail when on March 25 a police sergeant and another officer went to speak to him when they saw him parking up a different Renault Clio.
He was searched and three mobile phones were recovered as well as £290 in cash, a different lock knife and £5 worth of cannabis. The car was subsequently searched and cannabis worth £297 was found behind the headlamp panel.
Elyas Patel representing Hussain said he had started using cannabis a recreational user and when his dealer had got him hooked and running up a debt he was put under pressure to become a street peddler.
Hussain, 21, of Clara Street, Hillhouse, Huddersfield admitted two offences of possessing cannabis with intent to supply and two of possessing offensive weapons and was jailed for a total of two years.