<commit_before>import hudson.model.*;
import jenkins.model.*;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey;
import com.cloudbees.plugins.credentials.CredentialsScope;

// Variables
def env = System.getenv()
def root_Url = env['ROOT_URL']
def gitGlobalConfigName = env['GIT_GLOBAL_CONFIG_NAME']
def gitGlobalConfigEmail = env['GIT_GLOBAL_CONFIG_EMAIL']
def awsDefaultRegion = env['AWS_DEFAULT_REGION']
def dockerTLSVerify = env['DOCKER_TLS_VERIFY']
def dockerNetworkName = env['DOCKER_NETWORK_NAME']

// Constants
def instance = Jenkins.getInstance()

Thread.start {
    println "--> Configuring General Settings"

    // Base URL
    println "--> Setting Base URL"
    jlc = JenkinsLocationConfiguration.get()
    jlc.setUrl(root_Url)
    jlc.save()

    // Global Environment Variables
    // Source: https://groups.google.com/forum/#!topic/jenkinsci-users/KgCGuDmED1Q
    globalNodeProperties = instance.getGlobalNodeProperties()
    envVarsNodePropertyList = globalNodeProperties.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)

    newEnvVarsNodeProperty = null
    envVars = null

    if ( envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0 ) {
      newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty();
      globalNodeProperties.add(newEnvVarsNodeProperty)
      envVars = newEnvVarsNodeProperty.getEnvVars()
    } else {
      envVars = envVarsNodePropertyList.get(0).getEnvVars()
    }

    // Example
    //envVars.put("FOO", "bar")
    if ( awsDefaultRegion != null ) {
	envVars.put("AWS_DEFAULT_REGION", awsDefaultRegion)
    }
    
    // Set Docker environment
    if ( dockerTLSVerify != null && dockerTLSVerify.toBoolean()) {
        envVars.put("DOCKER_TLS_VERIFY", env['DOCKER_TLS_VERIFY'])
        envVars.put("DOCKER_HOST", env['DOCKER_HOST'])
        envVars.put("DOCKER_CERT_PATH", env['DOCKER_CLIENT_CERT_PATH'])
	envVars.put("DOCKER_NETWORK_NAME", env['DOCKER_NETWORK_NAME'])
    }

    // Jenkins SSH Credentials
    println "--> Registering SSH Credentials"
    def system_credentials_provider = SystemCredentialsProvider.getInstance()

    def ssh_key_description = "ADOP Jenkins Master"

    ssh_credentials_exist = false
    system_credentials_provider.getCredentials().each {
        credentials = (com.cloudbees.plugins.credentials.Credentials) it
        if ( credentials.getDescription() == ssh_key_description) {<commit_msg>Splitting out Docker env vars<commit_after>import hudson.model.*;
import jenkins.model.*;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey;
import com.cloudbees.plugins.credentials.CredentialsScope;

// Variables
def env = System.getenv()
def root_Url = env['ROOT_URL']
def gitGlobalConfigName = env['GIT_GLOBAL_CONFIG_NAME']
def gitGlobalConfigEmail = env['GIT_GLOBAL_CONFIG_EMAIL']
def awsDefaultRegion = env['AWS_DEFAULT_REGION']
def dockerTLSVerify = env['DOCKER_TLS_VERIFY']
def dockerHost = env['DOCKER_HOST']
def dockerCertPath = env['DOCKER_CLIENT_CERT_PATH']
def dockerNetworkName = env['DOCKER_NETWORK_NAME']

// Constants
def instance = Jenkins.getInstance()

Thread.start {
    println "--> Configuring General Settings"

    // Base URL
    println "--> Setting Base URL"
    jlc = JenkinsLocationConfiguration.get()
    jlc.setUrl(root_Url)
    jlc.save()

    // Global Environment Variables
    // Source: https://groups.google.com/forum/#!topic/jenkinsci-users/KgCGuDmED1Q
    globalNodeProperties = instance.getGlobalNodeProperties()
    envVarsNodePropertyList = globalNodeProperties.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)

    newEnvVarsNodeProperty = null
    envVars = null

    if ( envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0 ) {
      newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty();
      globalNodeProperties.add(newEnvVarsNodeProperty)
      envVars = newEnvVarsNodeProperty.getEnvVars()
    } else {
      envVars = envVarsNodePropertyList.get(0).getEnvVars()
    }

    // Example
    //envVars.put("FOO", "bar")
    if ( awsDefaultRegion != null ) {
	envVars.put("AWS_DEFAULT_REGION", awsDefaultRegion)
    }
    
    // Set Docker environment
    if ( dockerTLSVerify != null && dockerTLSVerify.toBoolean()) {
        envVars.put("DOCKER_TLS_VERIFY", env['DOCKER_TLS_VERIFY'])
    }
    if ( dockerHost != null ) {
        envVars.put("DOCKER_HOST", dockerHost)
    }
    if ( dockerCertPath != null ) {
        envVars.put("DOCKER_CERT_PATH", dockerCertPath)
    }
    if ( dockerNetworkName != null ) {
        envVars.put("DOCKER_NETWORK_NAME", dockerNetworkName)
    }

    // Jenkins SSH Credentials
    println "--> Registering SSH Credentials"
    def system_credentials_provider = SystemCredentialsProvider.getInstance()

    def ssh_key_description = "ADOP Jenkins Master"

    ssh_credentials_exist = false
    system_credentials_provider.getCredentials().each {
        credentials = (com.cloudbees.plugins.credentials.Credentials) it
        if ( credentials.getDescription() == ssh_key_description) {
{'fraction_non_alphanumeric': 0.1064276177760824, 'fraction_numerical': 0.0011443829868395957, 'mean_word_length': 4.340122199592668, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '663837', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1633, 'n_words': 269}