When the NBC sitcom “Parks and Recreation” came to its end after seven seasons, it was an emotional day for all of the cast and crew, says Jim O’Heir, who played Jerry Gergich, the kindhearted bumbler and butt of all jokes in the city of Pawnee’s parks department.

O’Heir was part of a talented ensemble that included Amy Poehler as Leslie Knope, Nick Offerman as Ron Swanson, Aziz Ansari as Tom Haverford, Aubrey Plaza as April Ludgate, Adam Scott as Ben Wyatt, Chris Pratt as Andy Dwyer, and Retta as Donna Meagle.

As each of them shot their final scenes, there were tears aplenty on the set.

But no one, O’Heir suspects, shed more than him.

“I was dreading this day,” O’Heir says. “Like, you can’t believe how I was dreading it. Because I’m an emotional guy.

“I’m embarrassed to tell you this,” he continues. “I was in New York last week and I went and saw ‘Like Water for Elephants’ on Broadway. I’ve got tears running down over a fake elephant that’s being played by humans. It’s not even a real elephant! But things are happening to the elephant.

“So I’m that guy. Good or bad, that’s who I am.”

In a normal week on set, the final scene for any of the actors would be marked with a shout: That’s a wrap for Jim on this episode, O’Heir explains. The two-part finale was different: That’s a series wrap — the very last scene — for each actor in turn.

“Those two weeks were awful,” O’Heir says. “So many tears and goodbyes.

“After the very last one of us, without speaking a word, this hug started,” he says of his final day he was Jerry — or Garry, his real name, which none of his co-workers knew for the first five seasons, or Barry, Larry or Terry, as they sometimes misremembered.

“Just the cast,” O’Heir says. “It just happened. We cried, and then laughed that we were crying. This has been the greatest experience of our lives, right?

“It was just this special place,” O’Heir says, as his voice cracks and his eyes get misty. “My God, whoever thought I’d show up here and get teary-eyed? I’m sorry to do that.”

There’s no need for regrets, he’s told, because his story, as laid out in his new memoir, “Welcome to Pawnee: Stories of Friendship, Waffles and Parks and Recreation,” is a moving one.

O’Heir, who left Chicago for Los Angeles about 30 years ago, had long been a working actor, the kind of guy you’d see as a guest star on cop shows and legal dramas, sitcoms and medical shows.

But a recurring actor on a series, or if he really dreamed, a series regular? That remained just out of reach. Until “Parks and Recreation.”

Small roles, big waffles

In an interview conducted over waffles, in honor of the breakfast food Leslie Knope loved almost as much as municipal bureaucracies, O’Heir described how he lived in fear of losing his role as Jerry for the first two years the series ran.

His character, and Retta’s Donna, were loosely defined when the series began, and they bonded over the actorly insecurity that created. (Retta will host O’Heir’s book event today in Los Angeles.)

“I didn’t know, and they didn’t know, who Jerry was going to be because Jerry didn’t exist,” O’Heir says. “When the show started there was no Jerry, there was no Donna, there was no Andy. So then I get this role and it starts.

“In the very beginning, it was very much, ‘Jerry goes up to Amy as Leslie and says ‘Leslie, you got a package,’ ” he says of the limited instructions his earliest appearances offered. “He was very much in the background.”

In the book, and at the table at More Than Waffles in Encino, not far from his house, O’Heir notes that when he got the job offer, his agents didn’t want him to do it.

“Not in a bad way,” he says. “I was a decent working actor at that point. They said this might feel like background work. There’s nothing wrong with background work, but at this point in my career I’m doing guest spots and pilots and stuff.”

But O’Heir knew that “Parks and Rec” was created by Greg Daniels, who adapted “The Office” for NBC, and Michael Schur, who was a producer on that show. And O’Heir loved “The Office.”

“I saw what happened to Kevin and Phyllis and Stanley and Angela and Meredith,” he says, rattling off the names of characters on “The Office” whose initially small parts grew and grew over the seasons. “So I’m like, ‘Oh, this is worth whatever the risk.’ If I end up miserable after a couple of episodes and I’m thinking there’s nothing there, I’ll be gone. That’s easy.”

Still, he worried through the six episodes of Season 1 and into Season 2 before small changes started to suggest Jerry was going to stick around.

“They’re just kind of bouncing me in scenes here and there,” O’Heir says. “It was Season 2, I guess. The B-story was the Parks people were gonna find dirt on each other, and Jerry was like, ‘This seems mean. I don’t know. I’m not comfortable with this.’ But then he’s like, ‘OK. I’m gonna do this.’

“Paul Schneider’s character, Mark Brendanawicz, comes in and I go, ‘Hey, Mark, I hear you have two unpaid parking tickets,’ ” he says. “Big deal, right?

“And he goes, ‘Oh, really, I heard that your adopted mom smokes pot,’ and he could see he horrified me. He goes, ‘Oh, you didn’t know she smoked pot?’ And Jerry goes, ‘I didn’t know I was adopted.’

“In the edit, when they saw my reaction, they went, ‘That’s it. We have found Jerry. He’s going to be that guy, He needs a clue,’ ” O’Heir says. “And that is how I was.”

Not a dirt book

O’Heir, who is the co-host of the podcast “Parks and Recollection,” did not just wake up one day and decide to write the first insider’s look at “Parks and Recreation.”

“Dude, I can’t really take any credit for it,” he says, explaining how a book agency in New York City contacted his manager to see if he’d be interested. He sent word he was — with one or two conditions.

“No. 1, I have no interest in writing a tell-all, like a dirt book, because one, I don’t really have any dirt — it was the greatest seven years of my life — and two, I’m just not that kind of person. I don’t see Jim O’Heir writing a dirt book on people.”

And yes, it is a very Jerry thing to say “No. 1” and then put “one” and “two” within it.

No problem, the agents said, and scheduled a Zoom call to hear what kind of nondirt stories he might share.

“We planned a two-hour Zoom call, and within 30 minutes — his name is Matt — he goes, ‘Jim, we’ll keep talking, but you have a book. You have a story to tell,’ ” O’Heir says. “That was like, oh wow, I guess, because these are just my stories. I lived it, and I don’t know, I’ve told them to other people as life goes on. So I didn’t think much of it.”

After a book proposal and meetings with publishers, and making sure that Daniels, Schur and Poehler were fine with him doing the book, eventually it went out to auction.

“I remember I was flying to Denver to judge a film festival and getting on the plane thinking, ohhhh, I might get off this plane and have a book deal. Ain’t I something,” O’Heir says, laughing at his naive hubris. “Well, 2 1/2 hours later, I get off that plane. There is no message. There is nothing. Oh hell, I totally read that wrong. So, whatever, it was disappointing.”

Later, the book agent texted and asked O’Heir and his agent to get on a call. After hellos, the book agent asked how his day had gone.

“I go, ‘Well, I was hoping it would be better,’ ” O’Heir says. “‘I know the auction was today and apparently we didn’t get any interest.

“He goes, ‘What are you talking about? It ended 15 minutes ago. It’s an all-day auction, ’” he continues. “I knew none of this. So I said, ‘Oh did anybody bid?’ He says yeah.

“I said, ‘Who?’ And he said, ‘All of them. Everybody bid. Everybody wants this book.’ So I was shocked.”