Cannot find Windows Agent command line to download jar file

Hi,

After creating an agent. I’ve received this message:

With two options to download the jar file. However, I cannot find any command line (console) on jenkins to execute the available code to download the jar file. My environment is Windows 10.

What type of agent is it? SSH? JNLP? What does the log say (“See log for more details”).

This is the type

This is the log:


SSHLauncher{host='localhost', port=22, credentialsId='rparada', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.KnownHostsFileKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[04/04/23 12:49:13] [SSH] Opening SSH connection to localhost:22.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 10 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 9 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 8 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 7 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 6 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 5 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 4 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 3 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 2 more retries left.
Connection refused: no further information
SSH Connection failed with IOException: "Connection refused: no further information", retrying in 15 seconds. There are 1 more retries left.
Connection refused: no further information
ERROR: Connection is not established!
java.lang.IllegalStateException: Connection is not established!
	at com.trilead.ssh2.Connection.getRemainingAuthMethods(Connection.java:988)
	at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPasswordAuthenticator.canAuthenticate(TrileadSSHPasswordAuthenticator.java:83)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1856)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
	at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:222)
	at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:173)
	at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:878)
	at hudson.plugins.sshslaves.SSHLauncher.lambda$launch$0(SSHLauncher.java:434)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
[04/04/23 12:51:58] Launch failed - cleaning up connection
[04/04/23 12:51:58] [SSH] Connection closed.

That doesn’t make any sense, you have the agent setup such that it should be connecting to the controller, so there shouldn’t be anything about SSH at all in the logs. When you select the option you have selected, you should have to launch the agent via the agent.jar yourself.

I guess the log was from the previous setup. I deleted that one and created a new one, I could download the agent.jar inside the remote folder on my pc. Now, in the log appears dots appearing without text. The status of the agent stills shows a red cross. And in the section projects tied to agent1 (the name of the agent), shows None. I want to be tied to a project called pythonCookies. I don’t know where to configure it. Thanks

Did you run the agent.jar on the system to connect the agent to the controller? When using the option you selected, you have to run the agent.jar from the agent system so that it connects to the controller and can run jobs.

I did this steps:

  1. Downloaded the agent.file into a local folder already configured at the agent configuration “Remote root directory”
  2. Inside this folder “jenkins-agent”, I’ve downloaded a .exe “64bits” from WinSW and created an xml file (both with name jenkins-agent) with the following content:
<service>    
	<id>jenkins8080agent</id>
	<name>Jenkins Agent for jenkins:8080</name>
	<description>This service is a service created from a minimal configuration</description>
	<executable>C:\Program Files\Java\jdk-17\bin\java.exe</executable>
	<argument>java -jar C:\Users\cttc\agent.jar -jnlpUrl http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent.jnlp -secret 6a24e49160f6906a9f17fcb0dc97c98d13b8bcecb3cdf3e518cfed4c5398d5d3 -workDir "C:\Users\cttc\jenkins-agent"</argument>
	<log mode="roll" />
	<onfailure action="restart" />
</service>

The argument tag was copied from the command provided by Jenkins
4) Open a cmd (administrator) and execute jenkins-agent.exe start

This action generated diverse files: …err.log / …wrapper.log and /…out.log. Unfortunately, it should create the folder named remoting as indicated at Internal data directory and, inside err.log I found this message:

Error: Could not find or load main class java -jar C:\Users\cttc\agent.jar -jnlpUrl http:..localhost:8080.rparada.manage.computer.agent1.jenkins-agent.jnlp -secret 6a24e49160f6906a9f17fcb0dc97c98d13b8bcecb3cdf3e518cfed4c5398d5d3 -workDir C:\Users\cttc\jenkins-agent
Caused by: java.lang.ClassNotFoundException: java -jar C:\Users\cttc\agent/jar -jnlpUrl http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent/jnlp -secret 6a24e49160f6906a9f17fcb0dc97c98d13b8bcecb3cdf3e518cfed4c5398d5d3 -workDir C:\Users\cttc\jenkins-agent

I don’t know what I’m missing, I’ve been following this video How to Install Jenkins Agent on Windows - YouTube

Remove java from the arguments, it should only be the arguments to pass to java.exe not the executable as well.

I get this error:

Unrecognized option: -jar agent.jar -jnlpUrl http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent.jnlp -secret 6a24e49160f6906a9f17fcb0dc97c98d13b8bcecb3cdf3e518cfed4c5398d5d3 -workDir C:\Users\cttc\jenkins-agent
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Take a look at the same video at this point, it shows the setup that you should be using.

I have the same xml content (I’ve just added the path to the agent.jar).

<service>    
	<id>jenkins8080agent</id>
	<name>Jenkins Agent for jenkins:8080</name>
	<description>This service is a service created from a minimal configuration</description>
	<executable>C:\Program Files\Java\jdk-17\bin\java.exe</executable>	
        <argument>-jar C:\Users\cttc\jenkins-agent\agent.jar -jnlpUrl http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent.jnlp -secret 6a24e49160f6906a9f17fcb0dc97c98d13b8bcecb3cdf3e518cfed4c5398d5d3 -workDir "C:\Users\cttc\jenkins-agent"</argument>
        <log mode="roll" />
	<onfailure action="restart" />
</service>

However, I still get the same error. Is it because I have java 17 instead of 11?

No, Java 17 will work. Can you try running the following on the command line?

"C:\Program Files\Java\jdk-17\bin\java.exe" -jar C:\Users\cttc\jenkins-agent\agent.jar -jnlpUrl http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent.jnlp -secret 6a24e49160f6906a9f17fcb0dc97c98d13b8bcecb3cdf3e518cfed4c5398d5d3 -workDir "C:\Users\cttc\jenkins-agent"

I get this:

C:\Users\cttc>"C:\Program Files\Java\jdk-17\bin\java.exe" -jar C:\Users\cttc\jenkins-agent\agent.jar -jnlpUrl http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent.jnlp -secret 6a24e49160f6906a9f17fcb0dc97c98d13b8bcecb3cdf3e518cfed4c5398d5d3 -workDir "C:\Users\cttc\jenkins-agent"
Apr 10, 2023 11:54:35 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using C:\Users\cttc\jenkins-agent\remoting as a remoting work directory
Apr 10, 2023 11:54:35 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to C:\Users\cttc\jenkins-agent\remoting
Failed to obtain http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent.jnlp?encrypt=true
java.io.IOException: Failed to load http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent.jnlp?encrypt=true: 403 Forbidden
        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

Ok, well that is a problem. Are you sure the Jenkins URL is correct? Are you running the agent on the same host as the server?

Jenkins was installed locally and the agent content is also located inside the same host. I only use localhost address. So, I access Jenkins using localhost:8080.

Can you access this URL from a browser as the same user? http://localhost:8080/rparada/manage/computer/agent1/jenkins-agent.jnlp?encrypt=true

When using that link, appears the regular fields to insert my credentials to access to jenkins but I doesn’t, instead, I receive this error:
image

Are you sure you setup the agent in the jenkins configuration already?

This is the current agent configuration:

Name: agent1
Number of executors: 1
Remote root directory: C:\Users\user\jenkins-agent
Labels: pythonCookies (same name as the task)
Usage: Only build jobs with labels expressions matching this node
Launch method: Launch agent by connecting it to the controller
Enable Disable WorkDir
Internal data directory: remoting
Enable Use WebSocket
Availability: Keep this agent online as much as possible

With this folder structure in jenkins-agent:

image

I’ve followed are guidelines from the video, but still getting same error.

I don’t know what the issue is, sorry.