Skip to content

Instantly share code, notes, and snippets.

@ivan-pinatti
Last active February 4, 2018 01:30
Show Gist options
  • Save ivan-pinatti/13d51cb2afa452013b597cadd36bf305 to your computer and use it in GitHub Desktop.
Save ivan-pinatti/13d51cb2afa452013b597cadd36bf305 to your computer and use it in GitHub Desktop.
Jenkins - Disable old insecure protocols via groovy script - #jenkins #groovy
#!groovy
// imports
import jenkins.model.Jenkins
import jenkins.security.s2m.*
// get Jenkins instance
Jenkins jenkins = Jenkins.getInstance()
// define protocols
HashSet<String> oldProtocols = new HashSet<>(jenkins.getAgentProtocols())
oldProtocols.removeAll(Arrays.asList("JNLP3-connect", "JNLP2-connect", "JNLP-connect", "CLI-connect"))
// set protocols
jenkins.setAgentProtocols(oldProtocols)
// save to disk
jenkins.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment