Disable Jenkins CLI Bee Bot July 13, 2022 10:54 Updated The content of this article has moved to the new documentation site. Related articles Disable Jenkins CLI across all controllers How to add Java arguments to Jenkins? 'HTTP full-duplex channel timeout' when using the Jenkins CLI Preparing for the new CloudBees License Certificate How to block access to URLs vulnerable to SECURITY-2349/CVE-2021-21648 Comments 4 comments Sort by Date Votes Henry Dobson August 03, 2017 16:03 Just been looking at this functionality myself and found I was able to disable CLI in a much simplier way: ``` #!groovyimport jenkins.*def enableCli = CLI.get()enableCli.setEnabled(false) ``` Being fairly green with Groovy and the Jenkins classes, how do these approaches differ? 0 Denys Digtiar December 19, 2017 03:25 Edited Hi Henry, This script automates the creation of the init script on top of disabling the CLI using the approach in an original security advisory. The approach has since been improved and this script is a bit outdated now Please refer to https://github.com/jenkinsci-cert/SECURITY-218 0 Allan Tony Selvan October 17, 2018 14:05 Is this document up-to-date? 0 Yeung Siu September 18, 2019 05:50 Edited I am getting the following error message with version 2.176.2 "groovy.lang.MissingPropertyException: No such property: jenkins for class: security" Below is my code. It seems the CLI is not part of the jenkins class anymore? import jenkins.model.*import jenkins.model.Jenkinsimport jenkins.model.Jenkins.*import jenkins.CLI.*import hudson.model.Userimport hudson.security.*import hudson.security.csrf.DefaultCrumbIssuerimport jenkins.security.s2m.AdminWhitelistRule jenkins.CLI.get().setEnabled(false) 0 Please sign in to leave a comment.
Comments
4 comments
Just been looking at this functionality myself and found I was able to disable CLI in a much simplier way:
```
#!groovy
import jenkins.*
def enableCli = CLI.get()
enableCli.setEnabled(false)
```
Being fairly green with Groovy and the Jenkins classes, how do these approaches differ?
Hi Henry,
This script automates the creation of the init script on top of disabling the CLI using the approach in an original security advisory. The approach has since been improved and this script is a bit outdated now
Please refer to https://github.com/jenkinsci-cert/SECURITY-218
Is this document up-to-date?
I am getting the following error message with version 2.176.2
"groovy.lang.MissingPropertyException: No such property: jenkins for class: security"
Below is my code. It seems the CLI is not part of the jenkins class anymore?
import jenkins.model.*
import jenkins.model.Jenkins
import jenkins.model.Jenkins.*
import jenkins.CLI.*
import hudson.model.User
import hudson.security.*
import hudson.security.csrf.DefaultCrumbIssuer
import jenkins.security.s2m.AdminWhitelistRule
jenkins.CLI.get().setEnabled(false)
Please sign in to leave a comment.