The 26-year-old, who began his career at Sheffield Wednesday, has won promotion in each of the last three seasons.
Lavery helped Sheffield United win promotion from League One into the Championship back in the 2016/17 season.
He then repeated the feat with Rotherham the following year.
And last season he was part of Bury side that clinched automatic promotion from League Two.
“I’m delighted to be here,” said Lavery.
“I had really positive conversations with the manager from the start.
"I could tell that it was a good group of coaches, a good group of players and good people around the club. That is really important.
“I had a really positive feeling about the club and I am usually quite good when it comes to gut feelings.
“I am a very honest player and I leave everything out there on the pitch.
"I am a hardworking player and I like to put defenders under pressure. I am a striker that likes to get in behind the backline.
"At every club, no matter where you are up and down the country, you need to have a good strike force.
“Every club that I have been with, competition is always good. You’re always working on each other to better each other and you’re always looking to keep everyone on their toes.”
Manager Darrell Clarke added: “I’m pleased to get Caolan in. He’s another piece of the jigsaw that we’re trying to put together here.
"He’s experienced and a hard worker, a grafter, which fits the bill in terms of what I’m after from centre forwards.
“It doesn’t do players any good to keep going out on loan, but he’s got a home now and He knows where the back of the net is.”