After years of battling knee injuries — to the point that right knee pain is what will force him into retirement once this season is done — it was CC Sabathia’s left shoulder that ultimately sidelined him for the ALDS.

The 39-year-old, who had hoped to be a part of the Yankees’ bullpen against the Twins, will instead have to sit and watch after his shoulder didn’t respond well after making his lone appearance out of the bullpen last week in Tampa Bay.

Sabathia ended up getting a cortisone shot, but he wasn’t recovered enough to win a spot on the roster, although both the left-hander and Aaron Boone expressed hope that he might be able to return if the Yankees advance in the postseason.

For now, though, there’s no guarantee he’ll get back on a mound again.

“Obviously, you guys know me, it’s tough … being here and not being able to participate in the playoffs,’’ Sabathia said Thursday at Yankee Stadium, a day before the series against Minnesota was set to begin.

“I didn’t want to put the team in jeopardy. I want the best opportunity for this team to win a championship. I feel like we have a good opportunity. I didn’t want to be selfish and go out there hurt and put the team in a bad spot.’’

Sabathia had said he was fine pitching in relief in his final postseason — and he even hinted he’d be OK if the Yankees had decided to keep him off the roster before the shoulder injury popped up.

Boone said it was a matter of Sabathia’s “shoulder not bouncing back.’’

Sabathia threw a simulated game at the Stadium on Tuesday before the decision was made to put him on the shelf.

“[He] threw the ball pretty well, but just not quite where it needs to be, [for him] to be in the kind of role we’re going to ask him to be in, where he’s potentially getting up on the spot and then maybe having to get up later in the game,’’ Boone said.

Instead of Sabathia, the Yankees will now have to find a different pitcher to fill out their bullpen to go along with high-leverage relievers Aroldis Chapman, Adam Ottavino, Zack Britton, Tommy Kahnle and Chad Green — if the right-hander isn’t used as an opener.

Whether Sabathia’s absence opens a spot for another left-hander remains to be seen. Tyler Lyons pitched just 12 2/3 innings this season. Stephen Tarpley struggled this season, but snuck onto the postseason roster a year ago.

Sabathia will now become a cheerleader, at least for the upcoming series.

The lefty admitted it was odd that after all he had been through with the right knee, which he intends to have replaced sometime in the future, it was the shoulder that got him.

“It’s something that I never dealt with, obviously, never having arm problems,’’ Sabathia said. “So [I’m] just trying to work through it, do things in the training room to try to get back out there and play some catch and see how it feels.”

And he said he’s not thinking about the possibility of not pitching again, whether it’s because the Yankees don’t advance to the ALCS or because he’s unable physically.

“I’m just looking forward to having a chance to participate in the playoffs, play in the playoffs, hopefully get healthy enough and just be around here for the playoffs,’’ said Sabathia, who finished with a 4.95 ERA in 107 1/3 innings over 23 games. “I’m not really focused on it being my last time or whatever, just trying to focus on winning the championship.’’