Cannot launch jenkins windows slave after upgrade - windows

I have just updated jenkins to 1.5. My windows slaves were disconnected during the upgrade and now I cannot connect them again. I start the windows slaves with:
javaws.exe slave-agent.jnlp
I get this error:
I can remote to the windows slaves just fine so they are running.

This is a new, known issue due to this Security Advisory. Additional information, including several fixes/workaround can be found HERE.
Personally, since our Jenkins is on a secured, private network, going to Manage Jenkins -> Configure Global Security, and under Project-based Matrix Authorization Strategy enable “connect” in the “slave” section, for user “Anonymous” was sufficient to get us working.

In order to always assure correct update, the following steps must occur:
How to update Jenkins Slave in Windows
go to services.msc type "je" to find jenkins slave service and stop it from running
do: sc delete jenkinsslave-c__h (or the name the service has)
to know the name of the service, go to services.msc and open "Jenkins Slave" properties (it is auto/ highlighted)
if it is only "marked for deletion" close "Services" window (this will effectively delete the service)
go to c:h\ dir (or the dir where jenkins is running) and delete all files, letting workspace dir untouched
for %i in (*) do if not %i == workspace del "%i"
open "Java Control Panel" (search "Configure Java" on start button) and set Security to Medium
Configure Path where Jenkins worspace will operate at http://server:8080/jenkins/computer/node_to_use/configure
go to http://server:8080/jenkins/computer/node_to_use and run "Launch"
do: file>install as service; ok.
go to services.msc and refresh with F5 in order to appear "Jenkins Slave"
stop the service
open properties, and in the LogOn tab at "This account:" insert ".\user" being the user the admin user of the machine (or as the tested used via GUI login). Insert the password.
Set to automatic start on boot with following conditions:
delayed mode;
2 retries on failure (1 minute interval)
Assure user has needed files and access permissions
Go to Computer Management (right click#My Computer > Manage)
System Tools > Event Viewer > (Windows Logs >) Application > right click and choose Properties > "Overwrite events as needed"
run Jenkins slave

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.

Azure Devops (VSTS) - Start build agent as an administrator (interactive mode) in a console

is there any way to setup the VSTS build agent to run at windows startup in the interactive mode (as an admin)?
Now I'm at the stage where I have installed and configured the agent to run in the interactive mode. So it is running in a console. In the Windows startup there is an entry:
c:\Windows\System32\cmd.exe /D /S /C start "Agent with AutoLogon" "C:\agent\run.cmd" --startuptype autostartup
So without any additional change it is kicked off at Windows startup and it starts in a console. However I need it to run in admin mode so I followed this link:
https://superuser.com/a/1274970
Basicly this one allowed me to setup another cmd.exe that pointed to the original cmd.exe (renamed) and I was able to mark it to run in admin mode. Unfortunately after this change the agent does not start with windows at all.
Is there any way to debug it or see the logs (applications that failed to start)?
Interestingly enough, when I double click on cmd.exe it always starts in admin mode...so there is some blocker on the machine that prevents it to execute the startup command when windows starts.
I've set up the agent to use an account, which is in the Administrators group on the machine. I thought it will start automatically as an admin using the modified cmd that is set up to always start with elevated privileges - It didn't.
Any help greatly appreciated.
Thanks,
Chris
I ran into the same problem and solved the issue by an entry in the Task Scheduler. The task is set up to Run with highest privileges and is triggered At system startup.
In combination with UAC set to Never notify, the task shown above runs as an admin and does not trigger user interactions for automated elevations. Note, that the CMD window is not visible since the task runs in the background.
EDIT: If the CMD window needs to run in the foreground one can enable Autologon for the Windows machine and configure the task to Run only when user is logged on.
Shortcut solution:
Create a runAgent.cmd file with content:
call "C:\agent\run.cmd" --startuptype autostartup
Create a shortcut runAgent.lnk of runAgent.cmd
For runAgent.lnk open Properties and enable: Shortcut > Advanced... > Run as administrator
Modify the registry key value of VSTSAgent in Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run to:
C:\WINDOWS\system32\cmd.exe /D /S /C start "Agent with AutoLogon" "C:\agent\runAgent.lnk"

Unable to execute the windows bash script on Jenkins slave

As a part of regression testing need to run the bash script on windows machine which actually open the chrome browser and traverse the website and generate the test report.
when i try to execute it through jenkins all the test cases are getting failed as its unable to open the browser, the same is getting passed when we logon to the remote windows server and execute the script manually.
NOTE: Have provided the same credentials on jenkins slave windows service
found below log on event manager
Activation of app Microsoft.Windows.Cortana_cw5n1h2txyewy!CortanaUI failed with error: This app can't be activated by the Built-in Administrator. See the Microsoft-Windows-TWinUI/Operational log for additional information.
Could you please help me here..
Hi can you enable the option Allow service to interact with desktop for the jenkins slave service on your windows slave machine.
You can enable it by going In services.msc > right click on service name > Properties > Log On > Allow service to interact with desktop

Windows Jenkins slave issues

I upgraded to the latest version of Jenkins, and now when I try to run a Jenkins build on a Windows slave I get the error: Unable to find a suitable SSH agent.
I followed the instructions here: https://issues.jenkins-ci.org/browse/JENKINS-28279
But they no longer work. I'm using Jenkins version 2.33
My suggested set up:
Install Jenkins Master as a Windows Service.
On the Master:
Navigate to Nodes.
Create a new node and give it a name like Node.
Set Description to "Slave for Deployments to "
Set # Executors to 5
Set Directory to C:\JenkinsSlave
On the Slave machine:
Open a browser to Jenkins Master URL
Navigate to Nodes > <New Slave Name>
Click the Launch button. A new (small) browser window will open.
ALTERNATE - If launch button wants to download slave-agent.jnlp
a) Save slave-agent.jnlp to c:\temp on slave machine
b) Ensure Java 1.8_66 is installed and %JAVA_HOME%\bin is in the Path (NOTE: %JAVA_HOME% may not work so you may have to put the full path to Java in the Path)
c) Open an Administrator Command Prompt and navigate to c:\temp
d) Type javaws -verbose c:\temp\slave-agent.jnlp
e) Accept the "Do you want to run" dialogs
f) When the browser window pops up select "Install as a Windows service" from the file menu
g) If installation fails due to access rights you will need navigate to C:\JenkinsSlave and type jenkins-slave.exe install
Select File > "Install as a windows service"
Go to Services > JenkinsSlave and open properties
Set Logon details appropriately and restart.
If "Install as a windows service" fails
On the slave machine:
Open an adminstrator Command Prompt
Change directory to C:\JenkinsSlave
Execute "slave.exe install" (without the quotes)
Return to step 5. above.

How to force Jenkins to launch webpage/ cmd prompt in client (user's) machine?

The job that I was trying to create in Jenkins would require launching a webpage on the user’s browser once the build is successful (Jenkins is installed on a remote server). For doing this I put the following line in the " Build - Execute Windows batch command" section of the job’s Configure page:
START http://google.com
While the build was successful, it did not launch the page. I have a hunch, this line will try to launch the webpage in the remote Jenkins server (it did not launch anything in the slave node though). My question is, how do I force the Jenkins job to launch the webpage in the user’s default browser?
I tried launching client's cmd.exe - this did not work either.
Jenkins master, slave, user's client - everything is on Windows. Jenkins version 1.46.
Thanks!
By "launch in client's machine" you mean the user that is accessing the web interface of Jenkins? No, this won't happen. It can be quite a security risk too.
You can do what you are asking either on the master or the slave. Jenkins does not directly execute anything that is not on master/slave. It is possible to spawn a slave on user's machine, and when the job is run, it will execute the command on the slave.
Or if the user provides his/her computer IP address as a parameter to the job, you could use PsExec to connect to user's computer to execute a command.

Resources