CarlMc
CarlMc

Reputation: 210

Powershell call works on server but returns error through jenkins

We recently got some new Windows Server 2019 machines and I want to add them to our Jenkins setup. The problem is: executing any external program causes an error. docker login, git status, java -version all give an error like this

[TestPowershell] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\XXX~1\AppData\Local\Temp\3\jenkins1416755497082623783.ps1'"
java : java version "1.8.0_101"
At C:\Users\XXX-sa\AppData\Local\Temp\3\jenkins1416755497082623783.ps1:1 char:1
+ java -version
+ ~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (java version "1.8.0_101":String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Java(TM) SE Runtime Environment (build 1.8.0_101-b13
)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
Notifying upstream projects of job completion
Finished: SUCCESS

Tried it on the server itself, works fine. All the setup is the same as our 2016 servers, which dont present this issue

EDIT: I setup a vanilla master on VM 2019 and it works without this error, still presents the error with a 2016 master.

Upvotes: 2

Views: 742

Answers (2)

CarlMc
CarlMc

Reputation: 210

For some reason, it seems that this is related to dotnet 4.8. Windows 2019 1809 ships with 4.7 which presents this strange error, not only does it happen on java -version, but git clone , npm install and ng build to name a few also cause the same error. Installing dotnet framework 4.8 fixes it.. in case anyone is having the same issue we were..

Upvotes: 1

Moerwald
Moerwald

Reputation: 11254

Per default jenkins-slave service runs under the SYSTEM user, under which e.g. git operations will fail, since the user credentials are missing.

In the Windows service control manager change the user of the jenkins-slave-service (properties - log on) the an user profile that has appropriate permissions.

Hope that helps.

Upvotes: 0

Related Questions