Jenkins windows slave auto reconnection - jenkins

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
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

Related

localhost refused to connect when trying to access jenkins on windows

I installed jenkins on my windows PC and it was installed successfully. I put the installation on port 8085 and was able to access jenkins by visiting localhost:8085, then I shut down my PC. However, the next day when I opened my PC again it gave localhost refused to connect!
I did not give a user while installing and it was running locally.
How do I resolve this?
I guess Jenkins was installed as windows service, so after restarting your PC Jenkins service on your machine was stopped.
For automatically starting your Jenkins service after failures, you should check properties of service --> recovery settings.

PLC4x docker container connection timeout to PLC

We've been trying to connect to a PLC but it's not working. We used the basic example "hello-world-plc4x" with JAVA from the PLC4x Github repo.
When we start the PLC4x from the console java -jar .\plc4j-datacare-plc4x-0.9.1-uber-jar.jar --connection-string s7://10.250.46.28 --field-addresses %DB67:10:INT[1] it's working but as soon as we build the container an start running the container it is not working because of the timeout error as you can see in the Docker log file:
Connection timeout
Can someone help us to fix the issue or does anyone have any suggestions?

SEVERE: https://jenkins.domainname.com/tcpSlaveAgentListener/ appears to be publishing an invalid X-Instance-Identity

We're trying to connect a previously connected agent to a Jenkins server.
We get the following error:
SEVERE: https://jenkins.domainname.com/tcpSlaveAgentListener/ appears to be publishing an invalid X-Instance-Identity.
java.io.IOException: https://jenkins.domainname.com/tcpSlaveAgentListener/ appears to be publishing an invalid X-Instance-Identity.
at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:287)
at hudson.remoting.Engine.innerRun(Engine.java:694)
at hudson.remoting.Engine.run(Engine.java:519)
The command to run the agent is:
java -jar agent.jar -jnlpUrl http://${private_ip}:8080/computer/mac/slave-agent.jnlp -secret ${secret} -workDir "/var/jenkins-sign"
We're running on a MacOS.
All TCP ports are open internally between the mac and the ${private_ip}. I have telnet working.
As said, this agent was recently connected to the server, but the agent had a restart. We also upgraded the Jenkins server to latest available version.
I updated the agent.jar file.
I think it's related to contacting ${private_ip} while the X-Instance-Identit says "jenkins.dommainame.com", but I am not sure how to resolve it.
I only saw that there were recently changes in this area, but not a lot of helpful information other than that.
Does anyone have an idea?
In case anyone else runs into the issue, in my case it was because I was passing the entire URL, i.e.
http://someurl/jenkins/computer/test/slave-agent.jnlp
and what it really wanted was
http://someurl/jenkins/
Unfortunately, I think it's related to Jenkins upgrade that caused this, and I'm not sure there's a better solution than what I found.
Putting here my solution, but if anyone knows something better, I'd be happy to hear about it :)
Download the agent.jar
Download the slave-agent.jnlp and modify it:
Change all occurrences of https://jenkins.mydomain.com to http://[private_ip]:[port].
Start the process: java -jar agent.jar -jnlpUrl "file:/path/to/dir/slave-agent.jnlp" -workDir "/path/to/dir"
Do not add the secret to this command.
If you're using Jenkins agent as a service, remove the -secret argument from the file.
Set global environment variable jenkins.agent.inboundUrl to your private adderess (with http/https) + port + suffix (if set).
This value will be used as url in JNLP file. This enables using a private address for inbound tcp agents, separate from Jenkins root URL.
see: https://issues.jenkins.io/browse/JENKINS-63222

Getting 401 Unauthorized error while trying to launch Jenkins slave via command line through JNLP using -secret option

I am trying to launch my Jenkins slave via command line through JNLP, so that I can put the command in the task scheduler. However, I am facing authentication issues only when I use the -secret option with the secret key generated by Jenkins. Works fine if I pass the -auth option with the same username password that I use for Jenkins.
java -jar slave.jar -jnlpUrl http://<jenkins host>:<port>/jenkins/computer/<Slave name>/slave-agent.jnlp -secret <secret_key> -workDir "C:\Jenkins\Robot"
Note: the command I try to execute is as is copied from Jenkins page.
It gives following error:
org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDirINFO: Using C:\Jenkins\Robot\remoting as a remoting work directory Both error and output logs will be printed to C:\Jenkins\Robot\remoting Not use http_proxy property or environment variable which is invalid: unknown protocol: one.proxy.att.com Failing to obtain http://<host:port>/jenkins/computer/<job>/slave-agent.jnlp?encrypt=true
java.io.IOException: Failed to load http://<host:port>/jenkins/computer/<job>//slave-agent.jnlp?encrypt=true: 401 Unauthorized
at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:485)
at hudson.remoting.Launcher.run(Launcher.java:316)
at hudson.remoting.Launcher.main(Launcher.java:277)
Waiting 10 seconds before retry
However, if I change command as follows, it runs successfully.
java -jar slave.jar -jnlpUrl http://<jenkins host>:<port>/jenkins/computer/<Slave name>/slave-agent.jnlp/slave-agent.jnlp -auth <user>:<pass> -workDir "C:\Jenkins\Robot"
I cannot keep my credentials in the launch file as this will remain in public shared repository. Pls help.
I think that your issue may come from a security management.
Have you enable TCP port for JNLP agents in your Global Security ?
Go to Manage Jenkins > Global Security, Enable TCP port for JNLP agents, select Fixed and fill the port you used in your jnlpUrl, then select Java Web Start Agent Protocol/4 and save your config.
Further documentation here.
I had a similar problem. I resolved it by allowing anonymous access to Jenkins (the option is available in Manage Jenkins page, Kerberos properties section - we use Kerberos Single Sign-On plugin for Jenkins authentication, so not sure how would other authentication plugins work).
I'd also recommend limiting the scope of anonymous access if you enable it.

Why am I not able to access Jenkins remotely?

My jenkins has suddenly stopped being accessed from a remote machine. I have tried the following command to open it from another machines:
java -jar jenkins.war --httpPort=8085 --httpListenAddresss=0.0.0.0
and then I am tried to open it using
http://hostname:8085
And
http://ip:8085
but I am not able to access it. To launch the slave on other machine I need to have access to that url.
note: I am able to ping to my host name from any remote machine.
I given access to all inbound and outbound connections from my firewall
You can see the correct URL in Nodes view:
Create dummy node with "Launch method" = "Launch agent via Java Web Start"
Save it
Choose this 'dummy' node
Jenkins should show you a command line with correct URL, i.e.
java -jar slave.jar -jnlpUrl http://myjenkinsserver:8080/computer/dummy/slave-agent.jnlp -secret c159219e557d0e612371b97d86f9a319584cf1c53b8ab9df73f34b46eed8865c

Resources