[JIRA] (JENKINS-61893) Warn about CLI command overrides or avoid them all

6 views
Skip to first unread message

manuelramonleonjimenez@gmail.com (JIRA)

unread,
Apr 14, 2020, 8:52:04 AM4/14/20
to jenkinsc...@googlegroups.com
Ramon Leon created an issue
 
Jenkins / Improvement JENKINS-61893
Warn about CLI command overrides or avoid them all
Issue Type: Improvement Improvement
Assignee: Unassigned
Components: core
Created: 2020-04-14 12:51
Priority: Minor Minor
Reporter: Ramon Leon

I've been working on an issue recently. While trying to call the disable-job cli method, we receive:

ERROR: object is not an instance of declaring class

The root cause is because a plugin has overriden the method: https://github.com/jenkinsci/multi-branch-project-plugin/blob/master/src/main/java/com/github/mjdetullio/jenkins/plugins/multibranch/TemplateDrivenMultiBranchProject.java#L480

So now, if you try to disable a Freestyle job, it fails because it's expecting a TemplateDrivenMultiBranchProject one.

I open this to have feedback about what is best to do here:

  • Avoid overriding cli methods
  • Warn about that fact on Jenkins console
  • Warn about that fact on Jenkins CLI commands list page
  • Warn about that fact on the CLI command output directly (may break some automations)
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

jglick@cloudbees.com (JIRA)

unread,
Apr 14, 2020, 9:29:04 AM4/14/20
to jenkinsc...@googlegroups.com
Jesse Glick commented on Improvement JENKINS-61893
 
Re: Warn about CLI command overrides or avoid them all

If a particular code pattern leads to a runtime error like this, we should define an annotation process for CLIMethod which reports the situation as an error. Then when the plugin is built against a newer core version the build will fail with an explanation.

More broadly, I would recommend deprecating CLIMethod in favor of explicit CLICommand using the regular extension point mechanism.

dbeck@cloudbees.com (JIRA)

unread,
Apr 14, 2020, 9:34:02 AM4/14/20
to jenkinsc...@googlegroups.com

More broadly, I would recommend deprecating CLIMethod in favor of explicit CLICommand using the regular extension point mechanism.

This wouldn't solve the underlying problem, because it looks like that has a similar behavior (silently accepting name collisions and picking one of the implementations when invoked).

jglick@cloudbees.com (JIRA)

unread,
Apr 14, 2020, 9:45:02 AM4/14/20
to jenkinsc...@googlegroups.com

Yes but this is just the regular behavior of extension points, not an error, and it is more apparent what is going on. It seems much less likely that the author of this plugin would have accidentally copied a CLICommand implementation than what actually happened, which is that they overrode a method and copied the annotations from the supertype (possibly prompted by an IDE, possibly by analogy with nullness annotations and the like).

Reply all
Reply to author
Forward
0 new messages