Windows Jenkins slave issues - windows

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.

Related

How to run a bat script on multiple windows servers at once?

I am trying to run a .bat script that uninstall 32/64 bit agents and re-install 64-bit agents on almost 100 window servers.
Can you please guide me how this can be done?
I already tried running for one server to test
psexec \\<windows server> -u <username> -p <password> <command>
But fails with error
COULD NOT START PSEXESVC service on <windows server>
Do we need such service on all machines? Please suggest any other way?
PSEXEC is not a standard windows feature /service.
If you wish to use PS Exec you will need to install it on all of the relevant systems first.
Otherwise, your options are:
CMD:
A) Does the "Agent" Installer you are using allow you to install / uninstall to a given server in it's command line syntax?
If so utilize that.
B) Put the Installer in central location (the Active Directory Netlogon Folder is great for this) along with a CMD script to run the uninstall and install processes.
Then Use SCHTasks to connect to each server and create a Scheduled task that runs using an administrative Username and password for that server, and set it to run with the highest privileges, set the action to be the path to the CMD script in netlogon that you have previously tested and nwo is working, set the task to run 1 minute in the future, or on demand (If on demand you then run schtasks again to execute the task).
Powershell:
Work on getting a working CMD Script to run and use Invoke Command to run that command script on the remote systems. As in Option B from CMD options you can keep the CMD script and Agent installer in the netlogon folder.

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"

tomcat a service with the given service name is already installed

I have to uninstall tomcat before reinstall it.But, I mistakenly deleted the file folder first and then uninstalled it from "control Panel", during this process I think somewhat might be got wrong. Now when I am trying to install it it is giving me the message:-
How can I overcome this?
it means that you have already installed a version of tomcat8 on your pc. But you can fix this problem by opening the cmd in administrator mode. then you start the command:
sc.exe delete tomcat8
That is because the server is not fully out of your computer, here follow these steps to remove the existing server on windows:
Navigate to Control Panel.
Open Administrative tools.
Open SERVICES.
You will find Apache tomcat version name, right click on it and open properties.
Cope the name of the server: Tomcat8/Tomcat9.
Now open and run the command prompt as an administrator:
https://www.thewindowsclub.com/how-to-run-command-prompt-as-an-administrator
Write the command: sc Delete Tomcat8/Tomcat9 and hit enter, the existing server is
removed and you are all set to install a new one.

Installing Jenkins Slave as Service on win8.1 and win10

I am trying to install Jenkins slave service after starting the slave via web start.
I get the following error when it tries to install on windows 10 and windows 8.1.
[JenkinsWorkDirectory]$ c:\JenkinsWorkDirectory\jenkins-slave.exe install
WMI.WmiException:AccessDenied
at WMI.WmiRoot.ClassHandler.Invoke(Object proxy, MethodInfo method, Object[] args)
at WMI.Win32ServicesProxy.Create(String, String, String, ServiceType, ErrorControl, StartMode, Boolean, String, String, String[])
at winsw.WrapperService.Run(String[]_args,ServiceDescriptor descriptor)
at winsw.WrapperService.Main(String[]args).
I can install the slave service without any issue on win 7.
Any idea why is this happening or is it some limitation of Jenkins or am i missing some dependency?
My jenkins version is 1.655 and using chrome browser when installing. Jenkins master is running on windows 7.
Thanks,
Daniel
I found another way to get the slave to install.
Open a command window with "Run as Administrator".
Change directory to the place where you saved the slave-agent.jnlp file.
at the prompt run "slave-agent.jnlp"
Now with the running slave click the menu item to "Install as Service".
The trick is to do it while running as an administrator. This installs the service running under localsystem.
Additionally, if you're like me and you need your jenkins routines to hit another machine, you'll need to change the service to run as a user with permission (network or otherwise) to do the task you want done.
Open a command window with "Run as Administrator".
Just in case, You may have trouble with the .jnlp in "Steve Brownell" instructions, then, run the first line of your error message, shown below.
c:\JenkinsWorkDirectory\jenkins-slave.exe install
goto your downloaded jenkins-slave.exe Application file.
goto properties -> compatibility -.> check run as administrator.
Now try installing it as service again. It will work.
"C:\Program Files (x86)\Java\jre1.8.0_161\bin\javaws.exe" slave-agent.jnlp just run this from command prompt my issue got resolved from this as an administrator

Cannot launch jenkins windows slave after upgrade

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

Resources