Omar Gonzalez, who has had psychiatric problems since fighting in Iraq, got credit for time already spent in jail so he will only have to serve eight more months.
His intrusion came in September 2014 and he has been in custody ever since, AFP reported.
"Good luck," Judge Rosemary Collyer said as she sentenced Gonzalez and expressed hope he will get his life together.
Gonzalez will be able to seek transfer to California, where his father lives. The judge recommended that 43-year-old Gonzalez serve the remainder of his term there and get follow-up treatment for mental problems.
Gonzalez apologized to the court and said he never meant to harm anyone.
On the evening of September 19, 2014 Gonzalez clambered over the north fence of the White House compound while carrying a pocket knife.
He ran 60 meters and entered the front door of the White House. He went through several rooms before being overpowered and arrested.
President Barack Obama and his family had just left the mansion.
The intrusion caused a howling controversy over the lapse of security. A probe was undertaken and the head of the Secret Service resigned.
Gonzalez pleaded guilty to "unlawfully entering a restricted building or grounds, while carrying a deadly or dangerous weapon" and one count of assaulting Secret Service officers.
His lawyer David Bos said his client is "someone who served his country. Theres a special consideration that should be warranted."
Prosecutor Thomas Gillice said Gonzalez "had a single-minded purpose: going to the White House" and that he also owned "an amazing" collections of guns.
But the judge said she wanted to show understanding toward the war veteran.
"Mr Gonzalezs life history shows that he had a civilized life until war," the judge said. "War clearly had an impact on his mental stability."
She said he was intelligent and stable so long as he is on medication.
"Im trying to make sure he gets his life back," Collyer said as she announced the sentence.
"We have lots of homeless people mentally ill in this country," the judge said.
"Were not going to let that happen. Were not going to let him become another homeless person in Washington, DC."
Gonzalez is barred from returning to Washington for the duration of his probation.