How to trace the debug breakpoints when job running any slave?

276 views
Skip to first unread message

Boyka Zhu

unread,
Jul 6, 2019, 8:03:36 AM7/6/19
to Jenkins Developers
Hi,

My plugin will run on remote slave, the java source codes which running on master  can be traced, but the codes which runs on slave cannot be traced, all breakpoints will be skipped.
If I setup the job running locally on master node, then all break points can be traced.

How to handle this? I really want to trace the breakpoints when running on slave,

Thanks
Boyka

Martin Weber

unread,
Jul 6, 2019, 8:23:37 AM7/6/19
to jenkin...@googlegroups.com
Am Samstag, 6. Juli 2019, 03:28:53 CEST schrieb Boyka Zhu:
> Hi,
>
> My plugin will run on remote slave, the java source codes which running on
> master can be traced, but the codes which runs on slave cannot be traced,
> all breakpoints will be skipped.

You need remote debugging.
Start the Java VM that runs the agent node with arguments that allow a
debugger to connect, like this
-agentlib:jdwp=transport=dt_socket,server=y,address=8000
See man java for details.

If you use Eclipse, you would then define a 'Remote Java Application' launch
configuration that connects to the agent node JVM. Just start that
configuration in debug mode and set your breakpoints.

Martin

--
There are only two hard problems in Computer Science: cache invalidation,
naming things, and off-by-one errors.




Ullrich Hafner

unread,
Jul 6, 2019, 9:51:58 AM7/6/19
to Jenkins Developers
You can have a look at my docker based development environment for my warnings plugin:

It starts the master and agent with open debugger ports so you can debug master and agent code. (There is also a predefined IntelliJ launcher provided to debug the remote applications.)

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/7040261.jTtysX6pI0%40linux.
For more options, visit https://groups.google.com/d/optout.

Boyka Zhu

unread,
Jul 8, 2019, 1:27:43 AM7/8/19
to Jenkins Developers
Thanks for the updates.
I tried below to launch the jar.
[root@hostname123 tmp]# java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8765 TESTPLUGIN.jar
Listening for transport dt_socket at address: 8765
no main manifest attribute, in TESTPLUGIN.jar
[root@hostname123 tmp]#

Is it possible to set the main class for Jenkins plugin entension point class? or just some changes in pom.xml.

Thanks.


在 2019年7月6日星期六 UTC+8下午8:23:37,Martin Weber写道:

Boyka Zhu

unread,
Jul 8, 2019, 1:28:04 AM7/8/19
to Jenkins Developers

Thanks.

在 2019年7月6日星期六 UTC+8下午9:51:58,Ullrich Hafner写道:
You can have a look at my docker based development environment for my warnings plugin:

It starts the master and agent with open debugger ports so you can debug master and agent code. (There is also a predefined IntelliJ launcher provided to debug the remote applications.)
Am 06.07.2019 um 14:23 schrieb Martin Weber <fifteen...@gmail.com>:

Am Samstag, 6. Juli 2019, 03:28:53 CEST schrieb Boyka Zhu:
Hi,

My plugin will run on remote slave, the java source codes which running on
master  can be traced, but the codes which runs on slave cannot be traced,
all breakpoints will be skipped.

You need remote debugging.
Start the Java VM that runs the agent node with arguments that allow a
debugger to connect, like this
-agentlib:jdwp=transport=dt_socket,server=y,address=8000
See man java for details.

If you use Eclipse, you would then define a 'Remote Java Application' launch
configuration that connects to the agent node JVM. Just start that
configuration in debug mode and set your breakpoints.

Martin

--
There are only two hard problems in Computer Science: cache invalidation,
naming things, and off-by-one errors.




--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkin...@googlegroups.com.

Martin Weber

unread,
Jul 9, 2019, 2:15:32 PM7/9/19
to jenkin...@googlegroups.com
Am Montag, 8. Juli 2019, 07:27:43 CEST schrieb Boyka Zhu:
> Thanks for the updates.
> I tried below to launch the jar.
> [root@hostname123 tmp]# java -jar
> -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8765
> TESTPLUGIN.jar

Just run agent.jar, not your plugin jar. You don't need TESTPLUGIN.jar on the
agent class-path.

In case you are running an ssh-node, you can just specify
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8765
for the JVM option on the jenkins node configuration page.

Boyka Zhu

unread,
Jul 15, 2019, 1:00:58 AM7/15/19
to Jenkins Developers
Hi Martin,

Thanks. Still, no works for me. What I did below:

1. Use Eclipse to start the Jenkins debug instance. Keep it running.
2. Add the remote slave.
3. Use command to start the agent on the remote slave.
[root@hostname123 boyka]# java -jar  -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8765  agent.jar -jnlpUrl http://myjenkinshost:8080/jenkins/computer/hostname123.dev.com/slave-agent.jnlp -workDir "/home/boyka/JenkinsDev"
Listening for transport dt_socket at address: 8765
Jul 15, 2019 12:52:21 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /home/czhu/JenkinsDev/remoting as a remoting work directory
Both error and output logs will be printed to /home/boyka/JenkinsDev/remoting
Jul 15, 2019 12:52:22 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: hostname123.dev.com
Jul 15, 2019 12:52:22 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Jul 15, 2019 12:52:22 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 3.29
Jul 15, 2019 12:52:22 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /home/boyka/JenkinsDev/remoting as a remoting work directory
Jul 15, 2019 12:52:22 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://myjenkinshost:8080/jenkins/]
Jul 15, 2019 12:52:22 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
Jul 15, 2019 12:52:22 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Agent discovery successful
  Agent address: myjenkinshost
  Agent port:    61616
  Identity:      f7:43:32:43:aa:d1:40:26:29:f2:5d:42:13:b8:bf:ea
Jul 15, 2019 12:52:22 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
Jul 15, 2019 12:52:22 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to dln-l-cz01:61616
Jul 15, 2019 12:52:22 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Trying protocol: JNLP4-connect
Jul 15, 2019 12:52:22 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Remote identity confirmed: f7:43:32:43:aa:d1:40:26:29:f2:5d:42:13:b8:bf:ea
Jul 15, 2019 12:52:23 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connected


2. Create one job which configured the TESTPLUGIN, and let the job running on the remote slave.

3. The breakpoints got passed directly.

What other steps needed? Appreciate your help deep in this.


在 2019年7月10日星期三 UTC+8上午2:15:32,Martin Weber写道:

Ullrich Hafner

unread,
Jul 15, 2019, 5:11:19 AM7/15/19
to Jenkins Developers
How do you connect the remote debugger with the agent?

-- 
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/799464cf-c4e3-45b5-8fb8-67f3ff7afa00%40googlegroups.com.

Boyka Zhu

unread,
Jul 17, 2019, 2:17:23 AM7/17/19
to Jenkins Developers
Hi Ullrich,

In the remote host, I use below command to start the agent.
java -jar  -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8765  agent.jar -jnlpUrl http://myjenkinshost:8080/jenkins/computer/hostname123.dev.com/slave-agent.jnlp -workDir "/home/boyka/JenkinsDev"

From my local desktop, I use eclipse to start the debug instance of the plugin.(eclipse debug configuration use "mvn:hpi"), then it start the Jetty and auto deploy Jenkins on it, in the same my test TESTPLUGIN will be ready for debug.

Any other point views?


在 2019年7月15日星期一 UTC+8下午5:11:19,Ullrich Hafner写道:
To unsubscribe from this group and stop receiving emails from it, send an email to jenkin...@googlegroups.com.

Pierre BEITZ

unread,
Jul 17, 2019, 5:45:33 AM7/17/19
to jenkin...@googlegroups.com
Hello Boyka

You're currently not attaching a debugger to the agent VM. Currently you have one debugger attached to the master JVM, but none to the agent JVM.

I'm not familiar with Eclipse itself but basically you want to create a Remote configuration that will attach to the agent VM (on port 8765 according to the configuration you sent). Look into the launch configuration in Eclipse, you should find something like Remote or Remote Java Application.

One way to quickly check the attaching works is to change suspend=n by suspend=y when launching your agent. This way the JVM will wait for the debugger to attach to proceed and you'll know that you attached properly. 

Hope this helps.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/a2e306a2-5cb1-4dcd-aed7-abfe63aa279e%40googlegroups.com.

Boyka Zhu

unread,
Jul 17, 2019, 6:50:51 AM7/17/19
to Jenkins Developers
Hi Pierre,

You tips work for me. 

Change suspend to y to start the agent, it will hold the listening at 8765 as I set, then start the remote java application with my remote host name and 8765 port, then the agent started.
Backup to eclipse, create some breakpoints which the sources codes will run at remote host,
Then from jenkins debug instance, click run job, then the breakpoint will hold the running. very good.

Thanks. ^_^

在 2019年7月17日星期三 UTC+8下午5:45:33,Pierre BEITZ写道:
To unsubscribe from this group and stop receiving emails from it, send an email to jenkin...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages