Secretary of Defense Jim Mattis defended the US border support mission in a visit with troops last Wednesday.

During his visit, Mattis repeated an oft-heard military mantra: “Just do your job.”

In his embattled role, the secretary has served a living example of this advice as he has taken differing positions than President Trump and even come under his scrutiny.

On Wednesday, US Secretary of Defense Jim Mattis stood in front of his troops at a base camp in Texas and answered questions about their ambiguous role on the US-Mexico border.

“What are the short-term and long-term plans for this operation?” one soldier asked.

Mattis explained that in the short-term, the troops were to continue laying obstacles to support the border patrol. Long-term goals, he said, had yet to be established. The question echoed sentiments rippling throughout the nation: This mission seems to be ill suited to active-duty troops, who are barred from law enforcement in the US.

The encounter gained media attention as one of Mattis’ usual attempts to justify unusual statements from his commander-in-chief, who had ordered the massive border deployment. Mattis’ Pentagon was reportedly at odds with President Donald Trump, who called the migrant caravan an “invasion,” and other agencies.

At the White House’s urging, the Department of Homeland Security requested that the Pentagon send armed US troops to the border to directly stop migrants, a request that Mattis personally rejected on the basis they were “inappropriate and legally treacherous,” according to the New York Times, which reported on these internal policy debates.

The border mission is hardly Mattis’ first skirmish with his boss, who recently suggested that the revered retired Marine general is “sort of a Democrat.”

Lees ook op Business Insider Medisch directeur Mariëlle Bartholomeus van ‘coronaziekenhuis’ Bernhoven verkozen tot topvrouw van het jaar

Less than a year after taking office, Trump issued a series of tweets that reversed an Obama-era decision to allow transgender troops to serve openly in the US military.

Read more: Trump tweets reveal plan to bar transgender people from serving in the military

On the heels of the announcement, and amid confusion across the country, Mattis tried to quell the controversy, saying his department would conduct a study to find the best path forward.

“In the interim, current policy with respect to currently serving members will remain in place,” Mattis said in a statement. Some of the Pentagon’s ban on service by transgender people has been overruled in federal court.

The former general also diverges from his commander in chief when it comes to support for NATO, which the president once called “obsolete” before reversing this stance as soon as three months later. Mattis has often stepped in to reassure the alliance that US support remains iron-clad.

In another instance, Mattis grabbed headlines when he stated the US military mission to Iraq was not an attempted oil-grab; this on the heels of an alarming statement from Trump to the CIA that “maybe you’ll get another chance” to do so in Iraq, according to a Reuters report.

The defense secretary faced scrutiny when he seemingly reversed his stance regarding Space Force. His approach to the president’s desire to launch a new military branch echoed that taken to head off the transgender ban: “What I was against was rushing to do that before we could define the problem,” he told reporters, denying he had reversed his position.

Mattis has had to defend his own positions from the president, whose comments have given rise to months of speculation that he was departing his post. When the president commented on Mattis’ political affiliation in an interview with CBS’ “60 Minutes,” Mattis again shrugged off the idea, telling the press he’s never registered for either political party.

Read more: Trump says Mattis is ‘sort of a Democrat’ and that the defense secretary ‘may leave’ the administration

In defending himself against his commander-in-chief’s remarks, Mattis referred back to advice he’s often given his own troops: “We just continue doing our job,” he told reporters.

That’s exactly the stance he’s taken throughout his tenure, trying to keep his troops and commanders focused on excecuting orders from the White House that have seemed unexpected and even erratic. So far, this seems to be his playbook for dealing with the president’s orders: deflect the media, motivate the troops, and quietly wait for the next.