Background / Environment:
Jenkins 2.3x on Ubuntu 20.04
I am trying to use a Jenkins Agent installed on the same system as Jenkins server. Ideally it will connect to just "localhost" when talking to the Jenkins controller.
Jenkins sits behind a reverse proxy which requires 2FA auth (using the official plugin).
If a reason for me using this local agent is needed, it's because having a standalone agent is a workaround for this bug.
Implementation:
Since the agent can't use the primary Jenkins URL as configured in settings (because that's the proxy URL with 2FA), Jenkins provides the setting -Dhudson.TcpSlaveAgentListener.hostName
to override the main server hostname setting. This is documented here.
I've set that value and can confirm that my "custom" name is set when querying the setting:
println(System.getProperty("hudson.TcpSlaveAgentListener.hostName") )
Returns:
http://localhost:8080
Which is the local listener of Jenkins and value I expect. I can curl
and wget
this address without issue from the host.
The problem
When starting the agent:
java -jar /data/jenkins_home/agent.jar \
-workDir "/data/jenkins_home/agent_workspace" \
-failIfWorkDirIsMissing \
-jnlpUrl http://localhost:8080/computer/local/jenkins-agent.jnlp
It tries (and fails) to connect to the primary Jenkins URL, ignoring the hudson.TcpSlaveAgentListener.hostName
setting
java.io.IOException: Failed to connect to <<MY_ACTUAL_JENKINS_URL>>
So, it's ignoring the hudson.TcpSlaveAgentListener.hostName
value. This seems to be the primary problem. How can I get it to not use the primary URL value and instead use the URL I give it?
- Everything works fine when the primary Jenkins URL is set directly to the host and not the proxy. However I can't have the agent connect through the proxy since it involves 2FA and is intended for humans to use. I've done several scripts against Jenkins using the direct hostname without issue, this the first time I've had an issue.
- Not using JNLP is an option but it's not well documented and I can't seem to get it going either. The documentation also states it REQUIRES a secret, and this local agent is meant to connect anonymously.
- I've tried with the agent config setting
Use WebSocket
enabled and disabled. Neither work.
- If I can just tell the agent to use a different URL this whole thing would be solved.
It seems like a simple thing just having an agent connect to a local listener, but apparently I mis-judged the complexity. I'm willing to pretty much configure whatever is needed to get this working so please do shout any ideas!