Cameras captured 24-year-old Michael Roberts arriving on a pushbike as drug users waited for him behind the station, Leeds Crown Court heard.
Prosecutor, Louise Pryke said the footage showed Roberts dealing drugs before starting to ride away on August 3 2018.
Police went to arrest Roberts, who had a bag containing cash and drugs.
He had 14 wraps of heroin, 17 wraps of crack cocaine and four deals of skunk cannabis.
Miss Pryke said police went to the address where Roberts lived at the time on Smawthorne Avenue, Castleford, and found 17 packets of skunk cannabis along with scales and dealer bags.
Roberts, of Broomhill Square, Knottingley, who has no previous convictions, admitted possessing class A drugs with intent to supply.
Roberts also pleaded guilty to possessing class B drugs with intent to supply.
Mark Foley, mitigating, said Roberts left school at 15 and had lived with travellers for a number of years.
Mr Foley said Roberts was estranged from his family and, after leaving the travellers, had started living in the stairwells at a block of flats in Castleford area.
Mr Foley said: "He started associating with drug users and homeless people.
"He was coaxed into and encouraged into earning some money by selling drugs and that's what he did."
Mr Foley said the Saviour Trust has since given Roberts somewhere to live and he has been working in a job with heavy machinery since June 2019.
Jailing Roberts for two-and-a-half-years, Judge Simon Batiste told him: "You must understand that people who deal in class A drugs, no matter what the circumstances, will go to prison."