4

I am stuck in a problem trying to install appx with Powershell -ExecutionPolicy Unrestricted add-appxpackage <path to appx> using the Powershell plugin in Jenkins and the below errors are logged:

add-appxpackage : Deployment failed with HRESULT: 0x80073CF9, Install failed. Please contact your software vendor. (Exception from HRESULT: 0x80073CF9) Deployment Add operation rejected on package <path to appx> install request because the Local System account is not allowed to perform this operation. NOTE: For additional information, look for [ActivityId].

As I understand, this problem is mainly because Jenkins service on Windows gets installed as NT Authority\System. (If I use psexec.exe to open a command prompt that runs as Authority\System, I run into the same issue.) I then tried adding net localgroup "Administrators" NT Authority\System /add hoping the group might get added as Administrator and would let me install the appx, so I can run the tests, but with no success. Now I am stuck and I am not sure if there is really a way to install an appx via Jenkins or not OR if there is a way to invoke the Powershell script as an administrator via Jenkins. I have been through couple of SO links already, but none of them seems to fix the issue I am facing. Any pointers would be appreciated.

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
learn_develop
  • 1,735
  • 4
  • 15
  • 33

1 Answers1

1

DO NOT try to add System to the Administrators group, it's a limited account for a reason and does not require administrative privileges.

Instead change the Jenkins service to run as a user that has the right permissions for what you're trying to do. That might mean you need to create an account specifically for the Jenkins service.

There are a few ways to change the service account, this answer gives the following as a solution:

sc.exe config "Service Name" obj= "DOMAIN\User" password= "password"
Community
  • 1
  • 1
arco444
  • 22,002
  • 12
  • 63
  • 67
  • Changing the master Jenkins Service to a specific user returns `Windows could not start Jenkins service on a Local Computer`. So, I guess it must be changed back to System. However, the main issue is the command prompt/Powershell window that is spawned by Jenkins on the Windows slave needs to run as administrator, otherwise the package installation would just not go through. And the Windows Slave can be running on a remote machine as well, where both the slave and master communicate via https://wiki.jenkins-ci.org/display/JENKINS/Swarm+Plugin – learn_develop Dec 07 '15 at 11:19
  • Wait a minute, it might have just got fixed on my system where the master and the slave are all on the same machine with the above solution. Will investigate how to do something similar where the slave is located remotely. – learn_develop Dec 07 '15 at 11:27
  • Just fixed the problem on the remote machine by making jenkins swarm service run as an administrator. Thank you. – learn_develop Dec 07 '15 at 13:33