Created
January 21, 2017 11:20
-
-
Save zouzias/bf447ab020955ac70db5db5521c3d5b9 to your computer and use it in GitHub Desktop.
Jenkins LDAP Groovy Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.* | |
import hudson.* | |
import com.cloudbees.plugins.credentials.* | |
import com.cloudbees.plugins.credentials.common.* | |
import com.cloudbees.plugins.credentials.domains.* | |
import com.cloudbees.jenkins.plugins.sshcredentials.impl.* | |
import hudson.plugins.sshslaves.*; | |
import hudson.model.* | |
import jenkins.model.* | |
import hudson.security.* | |
// Copied from https://github.com/zouzias/useful-jenkins-groovy-init-scripts/blob/master/init.groovy (untested) | |
def instance = Jenkins.getInstance() | |
/ NOW TIME TO CONFIGURE GLOBAL SECURITY | |
def hudsonRealm = new HudsonPrivateSecurityRealm(false) | |
// sample LDAP setup | |
String server = 'ldap://mycompany.com' | |
String rootDN = 'dc=company,dc=com' | |
String userSearchBase = '' | |
String userSearch = 'uid={0}' | |
String groupSearchBase = '' | |
String managerDN = 'cn=System,ou=people,dc=company,dc=com' | |
String passcode = 'passwordofSystem' | |
boolean inhibitInferRootDN = true | |
SecurityRealm ldap_realm = new LDAPSecurityRealm(server, rootDN, userSearchBase, userSearch, groupSearchBase, managerDN, passcode, inhibitInferRootDN) | |
instance.setSecurityRealm(ldap_realm) | |
instance.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dear Zouzias,
This groovy script runs successfully but no changes are done to Jenkins config.xml file thus no changes are applied (default is Jenkins database and whoever is logged can do anything).
Is there anything else that needs to happen after the groovy script runs? Is the passcode cleartext or hash?
I'd appreciate if you could clarify.
Thanks in advance!