Jenkins windows slave auto reconnect

Hi can anyone help me on the below issue…

i tried connecting my windows slave in cmd with this command and it was able to connect.

"java -jar agent.jar -jnlpUrl jenkins-agent.jnlp -secret -workDir “C:\jenkins”

but if i try running it through batch file in order to avoid manual connection each time i restart the system it was not able to connect. below is the error

Failed to obtain http:///computer/windows0slave0node/jenkins-agent.jnlp?encrypt=true
java.io.IOException: Failed to load http://
*/computer/windows0slave0node/jenkins-agent.jnlp?encrypt=true: 404 Not Found
at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:514)
at hudson.remoting.Launcher.run(Launcher.java:346)
at hudson.remoting.Launcher.main(Launcher.java:297)
Waiting 10 seconds before retry

my requirement is whenever i reboot my ec2 instance slave machine must be automatically connected with master without connecting it remotely

am using windows ec2 instance… please help on this

Reminder: Slave is a depreciated term, the proper term should be agent.

Without very much details its going to be hard to debug this. What type of agent are you creating? Is it a permanent jnlp agent? or some sort of ephemeral cloud one?

IF you goto the url with a logged in user does it give you a 404 as well?

if you goto the nodes/agents screen, does that name show up?

Am using a permanent jnlp agent

If i go the url its working fine…

If i run the java jar command through cmd it is working fine… but if i create a batch file and run that java jar command then this error pops out

Failed to obtain http:// /computer/windows0slave0node/jenkins-agent.jnlp?encrypt=true
java.io.IOException: Failed to load http://
*/computer/windows0slave0node/jenkins-agent.jnlp?encrypt=true: 404 Not Found
at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:514)
at hudson.remoting.Launcher.run(Launcher.java:346)
at hudson.remoting.Launcher.main(Launcher.java:297)
Waiting 10 seconds before retry

my requirement is whenever i reboot my ec2 instance agent machine it must be automatically connected with master without rdp into the machine

I don’t use ec2, so can’t speak to that or why you are getting a 404 from a batch file, but …

Have you investigated converting to running the agent as a service? That sould address the “automatically connected with master without rdp into the machine

Cloudbees described this on their site. They also have this post on Setting Up Jenkins EC2 Agents.

And there’s this "DevOps enthusiast’s extensive post on Configuring Jenkins Slaves (Linux+Windows) on AWS EC2

Not sure if any of it will help your specific circumstance, but it’s an alternative to the batch file approach.

ps: the JENKINS JIRA, is not a support site; it’s for defects, issues, enhancements, etc. Suggest closing out the ticket, unless you believe tere’s a bug.

Buenas tardes,

Esto mismo me sucedió, lo pude organizar desde el archivo jenkins-agent.xml en el agente remoto. Revisa ese archivo en la opción arguments, debes tener un parámetro malo para que no lo permita alcanzar el agente al servidor. Mira este video de como debes configurar el archivo xml.
How to Install Jenkins Agent on Windows - YouTube

Works if we use powershell, just rename your batch file to ps1 extension.