Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. // Harden Jenkins and remove all the nagging warnings in the web interface
  2. import jenkins.model.Jenkins
  3. import jenkins.security.s2m.*
  4.  
  5. Jenkins jenkins = Jenkins.getInstance()
  6.  
  7. // Disable remoting
  8. jenkins.getDescriptor("jenkins.CLI").get().setEnabled(false)
  9.  
  10. // Enable Agent to master security subsystem
  11. jenkins.injector.getInstance(AdminWhitelistRule.class).setMasterKillSwitch(false);
  12.  
  13. // Disable jnlp
  14. jenkins.setSlaveAgentPort(-1);
  15.  
  16. // Disable old Non-Encrypted protocols
  17. HashSet<String> newProtocols = new HashSet<>(jenkins.getAgentProtocols());
  18. newProtocols.removeAll(Arrays.asList(
  19. "JNLP3-connect", "JNLP2-connect", "JNLP-connect", "CLI-connect"
  20. ));
  21. jenkins.setAgentProtocols(newProtocols);
  22. jenkins.save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement