Install appx through Powershell Plugin via Jenkins - windows

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.

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"

Related

stop and start IIS server for TFS build Access denied

I need to stop and start IIS server for TFS build. When do this using .bat file iisreset /stop, similarly for start.
When I do this I get
Access denied, you must be an administrator of the remote computer to use this command. Either have your account added to the administrator local group of the remote computer or to the domain administrator global group.
Please note: This is Windows server 2019
I am already admin of this machine.
I have given read/write access to everyone in this folder.
I have unset EnableLUA to '0' in the registry as told in link for site
Above all these, I restarted machine.
I still get error in TFS build.
When you start a build in TFS the execution of that build is effectively done by a build agent. A build agent is just a service running on any particular machine. So, your batch file that shall start/stop the IIS service will be executed by whatever build agent is running your particular build.
This in terms means that your batch file is executed by the user that is used to run the build service. If that user does not have the necessary admin rights you face this particular error message.
What you need to do is make sure that all accounts that you use to run your build agents have administrative permissions on whatever machine you want to start/stop IIS.
You are trying to do IISRESET in your batch script. You need to be an Administrator as basic right to execute IISRESET command. So the account which the build is running needs to be part of the Admin group on the box.
Other approach is to stop and start w3svc using sc config commands or NET STOP WAS /Y and NET START W3SVC
Both of your answers are correct, I added the 'Network Service' of TFS to admin group of machine. Then build was success. Administrative tools>Computer Management> Local Users and Groups>Groups>
Inside Administrators and Users add 'Network Services'. If you don't find 'Network Service' then change location to your computer node and add them.

Bamboo remote build agent cannot find powershell.exe after installing nodejs

I just installed nodejs on one of my build servers (Win Server 2008 R2) which hosts a Bamboo remote agent. After completing the installation and doing a reboot I got stuck in the following situation:
The remote Bamboo build agent is running as a windows service with user MyDomain\MyUser. When a build with an inline powershell task is executing it fails with the error (from the build agent log):
com.atlassian.utils.process.ProcessNotStartedException: powershell could not be started
...
java.io.IOException: Cannot run program "powershell"
...
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
Loggin on to the server as MyDomain\MyUser, I have checked that powershell is in the path:
where powershell
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
I have tried to restart the service and reboot the machine multiple times. No luck. The only thing that works is if I execute my scripts as a bat file with an absolute path to powershell - but I do not want that.
I have searched for solutions on this, but even though this one seems related: Hudson cannot find powershell after update to powershell 3 - the proposed solutions do not work.
What am I missing here?
If you do a default installation of nodejs you will see that it adds nodejs and npm to the path. Sometimes I have seen that the installer adds a user variable named PATH - it might be that the Bamboo agent decides to read the user path without "merging" it with the system path. I think it would be worth a try to give that a look.
As per Atlassian support page, this is related to a bug in Java Service Wrapper. I tried Workaround-2 since there was no user PATH variable in my system. I had to uninstall bamboo agent service and Java 64 versions from the agent machine to apply the workaround-2.

Cannot run Nuget Package Restore from private Team City Nuget Server

Current discussion thread:
http://devnet.jetbrains.com/message/5519081#5519081
Bug Report: http://youtrack.jetbrains.com/issue/TW-37148
Error: Cannot prompt for input in non-interactive mode.
One thing to note is that the credentials prompt is triggering on each package download instead of at the beginning. I think this may be a bug in the way Team City is calling NuGet, but I'm not sure.
I have the "NuGet Feed Credentials" build feature configured, basic auth configured, and I've run the feed in Firefox and got the list of packages to show up on the agent machine (with credentials required).
My build log: https://gist.github.com/tonyeung/517597ca2312dad85f62
The following is a workaround which may help you, although I was of the impression the NuGet Feed Credentials build feature was meant to fix the problem. I was having a similar issue with the internal TeamCity NuGet feed without guest access (called Local in this example).
Initial build step (command line - custom script)
del /F %env.APPDATA%\NuGet\NuGet.Config
%teamcity.agent.tools.dir%\NuGet.CommandLine.DEFAULT.nupkg\tools\nuget.exe sources add -name Local -source %env.NuGetFeed%
%teamcity.agent.tools.dir%\NuGet.CommandLine.DEFAULT.nupkg\tools\nuget.exe sources update -Name Local -User %env.BuildServiceUser% -pass %env.BuildServicePassword%
As I say, it's a workaround, but not too much to maintain if using templates. Hopefully it gets you up and running.
I know this is an old question, but I recently came across this issue in TeamCity 9.1.7.
In my case, the issue was that I had a trailing slash on the Server URL, found in Administration > Global Settings. Removing that slash made the authentication work correctly.
For the TeamCity 8.1.2 (build 29993), I solved this issue by installing the Nuget v. 2.8.0 at the TeamCity Administration panel (I had v.2.8.2). Then I've added "Nuget Install" build step and set up the NuGet Feed Credentials build feature.
Probably, if you'll update the TeamCity it would also fix this issue.
To solve
http://localhost:80/httpAuth/app/nuget/v1/FeedService.svc: The V2 feed at 'http://localhost/httpAuth/app/nuget/v1/FeedService.svc/Packages(Id='***',Version='1.0.0')' returned an unexpected status code '401 Unauthorized'.
issue I have done:
create local administrator account
net user tcbagent password123 /add
net localgroup administrators tcbagent /add
attach "Logon as service" permissions (using Carbon PS helpers)
Grant-CAPrivilege -Identity tcbagent "SeServiceLogonRight"
create account within TeamCity
run cmd using destination environment
runas /user:tcbagent cmd
add nuget source with credentials
nuget sources add -name local -source http://localhost/httpAuth/app/nuget/v1/FeedService.svc -UserName tcbagent -Password password123
localhost of whatever you need
check your teamcity-build.log file to get something like this:
Starting NuGet.exe 3.5.0.1284 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT\tools\NuGet.exe
...
Restoring NuGet package xxxx.
...
Using credentials from config. UserName: tcbagent
TeamCity v9.1.7, NuGet v3.5.0-beta
I've spend 2 days to resolve it because I'm quite new with TeamCity and CI.
Hope it was helpful.
seem like a similar issue to https://nuget.codeplex.com/workitem/4172.
Can you try the workaround at the bottom of the issue description?

windows service installation "Administrator access is needed"

I am using NSSM (the Non-Sucking Service Manager) to install a windows service from a batch file like this
"nssm install C:\stash\runstash.bat"
but it throws:
"Administrator access is needed to install a service"
When I check user accounts in control panel, it shows that I am logged in with a User Name in the "Administrators" group.
Does anyone knows any possible reasons for this issue?
Thanks
You running it from command line, right? Then run with admin rights. There few possible ways:
right click on cmd shortcut, the run as administrator
execute cmd /admin
I believe you have UAC on on your PC, that's most programs run with user grant by defaul

Silent Install of DataStax Cassandra Community Edition from Windows Server fails

I am using the datastax-community-64bit_1.2.5.msi for installing on Windows VM. I am using the silent install command
msiexec /i
C:\ddapplications\cassandra\datastax-community-64bit_1.2.5.msi /quiet
/qn /le C:\ddapplications\cassandra\installlog.txt
If I run the installation command from the command line it installs as expected. No issues.
If I run the command from a Windows Service that runs as LocalSystem, I get the following error.
Is this a known issue? Is there a workaround? I also manually tried creating a group named WORKGROUP and adding the SYSTEM user to that group.
The SYSTEM user exists in the VM.
=== Logging started: 6/7/2013 23:52:23 === Error 1609. An error occurred while applying security settings. WORKGROUP\SYSTEM is not a
valid user or group. This could be a problem with the package, or a
problem connecting to a domain controller on the network. Check your
network connection and click Retry, or Cancel to end the install.
Unable to locate the user's SID, system error 1332
=== Logging stopped: 6/7/2013 23:52:25 ===
Is your VM in a domain? What is the service that you are using to trigger the installer running as?
A possible workaround may be to make that service run as Administrator.

Resources