BOSTON — The Yankees’ second half got off to a miserable start before they even took the field.

Michael Pineda has been diagnosed with a partially torn ulnar collateral ligament and a flexor strain in his right elbow, and Tommy John surgery has been recommended, general manager Brian Cashman said Friday on a conference call.

Pineda is getting a second opinion, Cashman added. Surgery would keep Pineda sidelined possibly until 2019. The 28-year-old will become a free agent after this season, meaning his stint in The Bronx is likely over.

The Yankees’ rotation already was dealing with plenty of issues: Masahiro Tanaka suffered through an ugly first half, CC Sabathia spent time on the disabled list after injuring his hamstring and Pineda was struggling after a fast start. He is 8-4 with a 4.39 ERA in 17 starts this season, but had a 6.14 ERA over his past seven starts.

The pitching woes contributed to the Yankees’ 7-18 stretch to close the first half that spoiled what had been an excellent start to the season. They opened the second half Friday at Fenway Park tied with the Rays for second in the AL East, 3 ½ games behind the Red Sox.

Pineda’s absence leaves a sizable void in the rotation, with two-plus weeks remaining until the trade deadline.

Cashman repeated Friday he remains a “careful buyer” and the loss of Pineda won’t turn the Yankees into sellers.

“The effort was to continue to find ways to see if I could import some support for the rotation,’’ Cashman said. “If we find a match we can live with that satisfies our present interests, as well as our future interests, then we’re all in. If we can’t, then I’ll do what I feel is disciplined and stay the course with the strategy we mapped out.”

The general manager acknowledged he talked with the White Sox about Jose Quintana, who was shipped across town to the Cubs on Thursday.

“We’re willing to do things to a certain extent.” Cashman said. “We’re certainly interested in improving the club. It depends on the price tag. If we feel there’s not something that benefits both the present and the future for us, then I don’t think it’ll be something we recommend too easily.’’

For his Yankees career, the often-frustrating Pineda is 31-31 with a 4.16 ERA.

According to Cashman, Pineda first complained of an issue with his elbow last Friday, two days after he gave up three homers in a loss to the Blue Jays. Manager Joe Girardi said it wasn’t uncommon for Pineda to experience soreness the day after his start, but the lingering pain raised red flags.

For now, the Yankees will turn to Bryan Mitchell for Sunday’s doubleheader and Luis Cessa next week in Minnesota. Sabathia, who isn’t scheduled to pitch this weekend, is fine physically.

Cashman said he wouldn’t rule out going to the trade market, though.

“I’ve been trying to add, not subtract,” Cashman said. “We’re engaged with everybody. I think we are going to treat this process the same as we did a week earlier or six months earlier.”

The news is especially ill-timed for Pineda, who is scheduled to hit the open market for the first time.

His results were mixed after coming to the Yankees from Seattle in exchange for Jesus Montero in January 2012.

Reflecting on Pineda’s inconsistent tenure with the Yankees, Cashman said he had expected to get a top-of-the-rotation starter.

“I think at times we saw that,” Cashman said. “I always thought there was more there. I still do. The ceiling should still be there [after elbow surgery]. I don’t think he’s a finished product.”