Error: Could not find or load main class com.mathworks.polyspace.jenkins.PolyspaceHelpers

99 views
Skip to first unread message

Stéphane BOBIN

unread,
Mar 1, 2024, 11:09:41 AM3/1/24
to Jenkins Developers
Hi!

I develop the Mathworks Polyspace plugin: https://github.com/jenkinsci/mathworks-polyspace-plugin

I have some helpers in my plugin to allow the users to call some utilities in the plugin from their script. It was working since the beginning but I recently realized it was not anymore. When I call them from a job in Jenkins, it fails:
 
java -cp /var/lib/jenkins/plugins/mathworks-polyspace/WEB-INF/lib/mathworks-polyspace.jar com.mathworks.polyspace.jenkins.PolyspaceHelpers
Error: Could not find or load main class com.mathworks.polyspace.jenkins.PolyspaceHelpers
Caused by: java.lang.ClassNotFoundException: com.mathworks.polyspace.jenkins.PolyspaceHelpers
 
When I call them from the server command line, it works:
 
> java -cp /var/lib/jenkins/plugins/mathworks-polyspace/WEB-INF/lib/mathworks-polyspace.jar com.mathworks.polyspace.jenkins.PolyspaceHelpers
Usage: ps_helper -report-filter <original_report> <filtered_report> [<owner>] [<title> <value>]+
Usage: ps_helper -report-status <report> <nb_to_fail>
Usage: ps_helper -report-count-findings <report>
Usage: ps_helper -print-runid <prs upload output>
Usage: ps_helper -print-projectid <prs upload output>
Usage: ps_helper -print-projecturl <prs upload output> <prs_url>
 
I checked the problem show even with my oldest plugin version which was supposed to work from the beginning. Anything has changed on Jenkins’ side with newer versions? Is there anything recently that forbids calling helpers from a job that way?

Any help understanding what is happening would be welcome!

Stéphane

Basil Crow

unread,
Mar 1, 2024, 1:26:18 PM3/1/24
to jenkin...@googlegroups.com
This seems to assume the build is running on the built-in node,
something we no longer recommend:

https://www.jenkins.io/doc/book/security/controller-isolation/#not-building-on-the-built-in-node

Stéphane BOBIN

unread,
Mar 1, 2024, 5:44:01 PM3/1/24
to jenkin...@googlegroups.com
Hi Basil,

Thanks for your prompt answer and the link. It makes sense and it seems to explain my problem. However, I couldn't find anything on how to move forward on this. 

Would you please point me to the right direction on:

- What is the recommended and secure way to have scripts on agents to call utilities from the plugin?

Thanks for your help!

-- Stéphane BOBIN

--
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/CAFwNDjpDZynbXQfmPXqTX1sTBrq7Ot2ZhY%2B2c18U6JZMcSSOcg%40mail.gmail.com.

Daniel Beck

unread,
Mar 1, 2024, 6:40:37 PM3/1/24
to jenkin...@googlegroups.com
On Fri, Mar 1, 2024 at 11:43 PM Stéphane BOBIN <stephane...@gmail.com> wrote:
- What is the recommended and secure way to have scripts on agents to call utilities from the plugin?

It's not a common enough use case to have a general recommendation.

Some ideas: publish the utilities separately rather than as part of the plugin, integrate them as tools into Jenkins (ToolInstallation / ToolInstaller), implement their functionality as build step(s), provide a build step to copy them to the workspace, or make them available for download from Jenkins like the agent.jar (with some care to not allow downloading anything else).

Stéphane BOBIN

unread,
Mar 3, 2024, 2:46:12 AM3/3/24
to jenkin...@googlegroups.com
Hi Daniel!

I like the idea. Do you have some more guidance, please? I found this: https://javadoc.jenkins.io/hudson/tools/ToolInstallation.html. But it does not explain a lot. Can you point me to the doc for the various items you suggest? A big thanks for your help!

-- Stéphane BOBIN

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

Baptiste Mathus

unread,
Mar 4, 2024, 3:42:06 AM3/4/24
to jenkin...@googlegroups.com
o/

Usually the best way to implement something is to look at how other plugins are doing it. The easiest way to find these existing implems is using https://www.jenkins.io/doc/developer/extensions/jenkins-core/#toolinstallation

Then, beware to read a few examples of ideally well-known plugins (theory being that there's greater chance to see idiomatic Jenkins code in a plugin installed 100k times, than one installed 10 :)).

Cheers

Reply all
Reply to author
Forward
0 new messages