Disable Jenkins CLI

Jenkins setup: Jenkins version : 2.443

How can we disable Jenkins CLI without having to use the groovy script provided here .

When we use the script from above, we are seeing some errors which we want to avoid.

If there is any workaround please do share.

Thanks.

Jenkins 2.443 is not affected by the security vulnerability. So you can just remove the init.groovy script.

I could remove the init.groovy, but was hoping for any other way to disable jenkins cli.

You intend to disable the CLI permanently also the security issue is solved in the Jenkins version you’re using?

Yes I want to disable the Jenkins CLI permanently.
Yes, I am using jenkins 2.443 which should not actually have any security issue.
We personally would like jenkins to only work through GUI or API , so we are trying to remove the Jenkins CLI which uses jenkins-cli.jar to trigger builds etc.

I think the problem you have is this bug in Blue Ocean, which prevents that the script works.
So you could uninstall Blue Ocean and use pipeline-graph-view instead. Blue Ocean is anyway in maintenance mode (so no new features are added and only bigger bugs are fixed afaik).

Thanks for the suggestion, we will look into the plugin “pipeline-graph-view”. Looks like a good replacement.

Meanwhile I have tried below script in init.groovy to avoid errors:

def removal = { lst ->

lst.each { it -> if (it.getClass().name?.contains("CLIAction")) lst.remove(it) }

}

def j = jenkins.model.Jenkins.get();

removal(j.getExtensionList(hudson.cli.CLIAction.class))

//removal(j.getExtensionList(hudson.ExtensionPoint.class))

removal(j.getExtensionList(hudson.model.Action.class))

removal(j.getExtensionList(hudson.model.ModelObject.class))

removal(j.getExtensionList(hudson.model.RootAction.class))

removal(j.getExtensionList(hudson.model.UnprotectedRootAction.class))

//removal(j.getExtensionList(java.lang.Object.class))

removal(j.getExtensionList(org.kohsuke.stapler.StaplerProxy.class))

removal(j.actions)

Basically commenting the lines causing unnecessary errors.

Any insight on any issue that would come because of above commenting?