Last active
October 18, 2019 19:47
-
-
Save nolte/327012a1fce3511e30cacaf2862c1c23 to your computer and use it in GitHub Desktop.
This file contains 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
// setup Maven | |
import jenkins.model.* | |
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.markup.RawHtmlMarkupFormatter | |
import hudson.slaves.EnvironmentVariablesNodeProperty | |
import hudson.security.FullControlOnceLoggedInAuthorizationStrategy; | |
import hudson.security.LDAPSecurityRealm; | |
// configure default maven | |
a=Jenkins.instance.getExtensionList(hudson.tasks.Maven.DescriptorImpl.class)[0]; | |
b=(a.installations as List); | |
b.add(new hudson.tasks.Maven.MavenInstallation("apache-maven-3.3.3", "/var/lib/maven/apache-maven-3.3.3", [])); | |
a.installations=b | |
a.save() | |
// configure default maven end | |
// configure git ssh connection | |
def privateKey = """-----BEGIN RSA PRIVATE KEY----- | |
DEN GIEBT ES JETZT NICHT AUCH NOCH ;) | |
-----END RSA PRIVATE KEY----- | |
"""; | |
global_domain = Domain.global() | |
credentials_store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore() | |
credentials = new BasicSSHUserPrivateKey(CredentialsScope.GLOBAL,"gitlab","jenkins",new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource(privateKey),"","gitlab connection") | |
credentials_store.addCredentials(global_domain, credentials) | |
// configure git ssh connection end | |
// Allow Markup-Formatter (Safe HTML) | |
Jenkins.instance.setMarkupFormatter(new RawHtmlMarkupFormatter(false)) | |
Jenkins.instance.save() | |
// Allow Markup-Formatter (Safe HTML) end | |
// Set Global System Properties | |
instance = Jenkins.getInstance() | |
globalNodeProperties = instance.getGlobalNodeProperties() | |
envVarsNodePropertyList = globalNodeProperties.getAll(EnvironmentVariablesNodeProperty.class) | |
newEnvVarsNodeProperty = null | |
envVars = null | |
if ( envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0 ) { | |
newEnvVarsNodeProperty = new EnvironmentVariablesNodeProperty(); | |
globalNodeProperties.add(newEnvVarsNodeProperty) | |
envVars = newEnvVarsNodeProperty.getEnvVars() | |
} else { | |
envVars = envVarsNodePropertyList.get(0).getEnvVars() | |
} | |
envVars.put("MY_FIRST_ENV", "http://localhost") | |
instance.save() | |
// Set Global System Properties End | |
/** | |
jenkins = Jenkins.getInstance() | |
jenkins.authorizationStrategy = new FullControlOnceLoggedInAuthorizationStrategy() ; | |
jenkins.securityRealm= new LDAPSecurityRealm(server="ldaps://ldap.linagora.com", rootDN = "", userSearchBase="", userSearch="uid={0}", groupSearchBase="", groupSearchFilter="", groupMembershipStrategy = null, managerDN = "", managerPasswordSecret = null, inhibitInferRootDN = false, disableMailAddressResolver = false, cache = null); | |
jenkins.save() | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment