Alexander Barker was arrested after officers saw him leaving the property on Rockley Drive in Kettlethorpe, in the early hours of April 26 this year.
Leeds Crown Court heard the 21-year-old tried to run off when he saw the officers and threw a rucksack he was carrying into a garden.
Officers used pepper spray as they detained the defendant.
The rucksack was recovered and found to contain drugs worth around £1,500.
Adam Walker, prosecuting, said the drugs included cocaine, ketamine, skunk cannabis and cannabis oil.
An extendable baton was also inside the bag along with a cannabis grinder, three mobile phones and keys to his home.
Further drugs were found when his home was searched.
The mobile phones contained text messages relating to the supply of drugs.
Barker, of Avon Croft, Ossett, pleaded guilty to possessing a class A drug with intent to supply, three counts of possessing a class B drug with intent to supply and possessing an offensive weapon.
Satpal Roth-Sharma, mitigating, said Barker pleaded guilty to the offences at an early stage and has no previous convictions.
Ms Roth-Sharma described Barker as a hardworking man who comes from a supportive family.
A probation service report assessed him as a low risk of reoffending.
Barker was jailed for 30 months.
Recorder Margia Mostafa said the offences were too serious to impose anything other than an immediate custodial sentence.
She said: "I take into account all that has been said on your behalf.
"The difficulty is that Class A drug dealers go to prison.
"You had a selection of drugs ready for sale.
"As much as I regret having to send you to custody, this out of my hands when you deal in that type of drug."