A former Walnut Creek police officer was sentenced Friday to a year in jail for attacking a woman with a baseball bat last month in Richmond while wearing a mask.

Gregory Thompson, who retired from the Walnut Creek force, pleaded no contest last month to assault, vandalism and a weapons enhancement for being armed when he accosted a woman on the 4100 block of Clinton Avenue near busy San Pablo Avenue about 2 a.m. Aug. 16.

At a hearing Friday in Martinez, Judge Bruce Mills of Contra Costa County Superior Court ordered Thompson, 54, of Martinez to serve a year in county jail and placed him on three years of felony probation. He is eligible to serve six months on home detention under electronic monitoring and earn good-time credit for the other six months, authorities said.

“It’s a fair disposition,” said prosecutor Barry Grove. “You have a 50-something-year-old guy with no criminal record, who’s worked a job his whole life. He did something bad, and he got sentenced appropriately considering the level of the crime and his lack of criminal history.”

Thompson’s attorney Amanda Bevins said, “We were satisfied with this disposition because it enables Mr. Thompson to remain gainfully employed and continue to do community work and work with veterans that he has devoted considerable time to for many years.”

Thompson was off duty and wearing a mask and gloves when he went after the woman, whom he believed may have been trying to break into a nearby home that his family was trying to sell for $289,000, in order to seek shelter, authorities said.

Thompson also used the bat to strike the woman’s car, Grove said.

In fact, the woman had run out of gas and was walking in the neighborhood, investigators said.

Police received 911 calls about a woman screaming and were directed by a witness to Thompson, who was nearby in his car, Richmond police Capt. Bisa French said. The woman emerged from bushes and was taken to a hospital.

Police found a mask, flexible ties similar to those used by officers and two handguns in Thompson’s car, French said.

A woman who tried to help the alleged victim may have also been injured, but she was not found by officers.

Thompson, a 30-year veteran, retired from the Walnut Creek police force last month, Chief Tom Chaplin said.

Henry K. Lee is a San Francisco Chronicle staff writer. E-mail: [email protected] Twitter: @henryklee