<commit_before>/*
 Variables consumed for this job:
      DEPLOYMENTS: 
        environments:
          environment 
            bastion_host: DNS address of bastion host 
            ssh_access_credentials: SSH access key of bastion host
      SECURE_GIT_CREDENTIALS: secure-bot-user 
      NOTIFY_ON_FAILURE: <EMAIL>

    This job expects the following credentials to be defined on the folder
    ubuntu-deployment-201407:   ubuntu deployment ssh access key
    ubuntu-mckinsey-deployment: mckinsey deployment ssh access key
*/

package devops.jobs
import static org.edx.jenkins.dsl.Constants.common_logrotator
import static org.edx.jenkins.dsl.Constants.common_wrappers


class ReadOnlyAccessToDB {

    public static def job = { dslFactory, extraVars ->
        assert extraVars.containsKey('DEPLOYMENTS') : "Please define DEPLOYMENTS. It should be a list of strings."
        assert !(extraVars.get('DEPLOYMENTS') instanceof String) : "Make sure DEPLOYMENTS is a list and not a string"
        extraVars.get('DEPLOYMENTS').each { deployment, configuration ->
            configuration.environments.each { environment,bastion_config ->
                dslFactory.job(extraVars.get("FOLDER_NAME","Monitoring") + "/access-to-${environment}-${deployment}-bastion") {
                       
                    logRotator common_logrotator
                    wrappers common_wrappers
                    wrappers {
                        sshAgent(bastion_config.get('ssh_access_credentials'))
                    }

                    
                    def gitCredentialId = extraVars.get('SECURE_GIT_CREDENTIALS','')

                    parameters{
                        stringParam('CONFIGURATION_REPO', extraVars.get('CONFIGURATION_REPO', 'https://github.com/edx/configuration.git'),
                                    'Git repo containing edX configuration.')
                        stringParam('CONFIGURATION_BRANCH', extraVars.get('CONFIGURATION_BRANCH', 'master'),
                                'e.g. tagname or origin/branchname')
                        stringParam('CONFIGURATION_SECURE_REPO', extraVars.get('CONFIGURATION_SECURE_REPO',"<EMAIL>:edx-ops/${deployment}-secure.git"),
                                'Secure Git repo .')
                        stringParam('CONFIGURATION_SECURE_BRANCH', extraVars.get('CONFIGURATION_SECURE_BRANCH', 'master'),
                                'e.g. tagname or origin/branchname')
                        stringParam('CONFIGURATION_INTERNAL_REPO', extraVars.get('CONFIGURATION_INTERNAL_REPO',"git@github.com:edx/${deployment}-internal.git"),
                                'Secure Git repo .')
                        stringParam('CONFIGURATION_INTERNAL_BRANCH', extraVars.get('CONFIGURATION_INTERNAL_BRANCH', 'master'),
                                'e.g. tagname or origin/branchname')
                    }

                    multiscm{
                        git {
                            remote {
                                url('$CONFIGURATION_REPO')
                                branch('$CONFIGURATION_BRANCH')
                            }
                            extensions {
                                cleanAfterCheckout()
                                pruneBranches()
                                relativeTargetDirectory('configuration')
                            }
                        }
                        git {
                            remote {
                                url('$CONFIGURATION_SECURE_REPO')
                                branch('$CONFIGURATION_SECURE_BRANCH')
                                if (gitCredentialId) {
                                    credentials(gitCredentialId)
                                }
                            }
                            extensions {
                                cleanAfterCheckout()
                                pruneBranches()
                                relativeTargetDirectory('configuration-secure')
                            }
                        }
                        git {
                            remote {
                                url('$CONFIGURATION_INTERNAL_REPO')
                                branch('$CONFIGURATION_INTERNAL_BRANCH')
                                if (gitCredentialId) {
                                    credentials(gitCredentialId)
                                }<commit_msg>Move bastion user list to internal, remove secure<commit_after>/*
 Variables consumed for this job:
      DEPLOYMENTS: 
        environments:
          environment 
            bastion_host: DNS address of bastion host 
            ssh_access_credentials: SSH access key of bastion host
      SECURE_GIT_CREDENTIALS: secure-bot-user 
      NOTIFY_ON_FAILURE: <EMAIL>

    This job expects the following credentials to be defined on the folder
    ubuntu-deployment-201407:   ubuntu deployment ssh access key
    ubuntu-mckinsey-deployment: mckinsey deployment ssh access key
*/

package devops.jobs
import static org.edx.jenkins.dsl.Constants.common_logrotator
import static org.edx.jenkins.dsl.Constants.common_wrappers


class ReadOnlyAccessToDB {

    public static def job = { dslFactory, extraVars ->
        assert extraVars.containsKey('DEPLOYMENTS') : "Please define DEPLOYMENTS. It should be a list of strings."
        assert !(extraVars.get('DEPLOYMENTS') instanceof String) : "Make sure DEPLOYMENTS is a list and not a string"
        extraVars.get('DEPLOYMENTS').each { deployment, configuration ->
            configuration.environments.each { environment,bastion_config ->
                dslFactory.job(extraVars.get("FOLDER_NAME","Monitoring") + "/access-to-${environment}-${deployment}-bastion") {
                       
                    logRotator common_logrotator
                    wrappers common_wrappers
                    wrappers {
                        sshAgent(bastion_config.get('ssh_access_credentials'))
                    }

                    
                    def gitCredentialId = extraVars.get('SECURE_GIT_CREDENTIALS','')

                    parameters{
                        stringParam('CONFIGURATION_REPO', extraVars.get('CONFIGURATION_REPO', 'https://github.com/edx/configuration.git'),
                                    'Git repo containing edX configuration.')
                        stringParam('CONFIGURATION_BRANCH', extraVars.get('CONFIGURATION_BRANCH', 'master'),
                                'e.g. tagname or origin/branchname')
                        stringParam('CONFIGURATION_INTERNAL_REPO', extraVars.get('CONFIGURATION_INTERNAL_REPO',"<EMAIL>:edx/${deployment}-internal.git"),
                                'Secure Git repo .')
                        stringParam('CONFIGURATION_INTERNAL_BRANCH', extraVars.get('CONFIGURATION_INTERNAL_BRANCH', 'master'),
                                'e.g. tagname or origin/branchname')
                    }

                    multiscm{
                        git {
                            remote {
                                url('$CONFIGURATION_REPO')
                                branch('$CONFIGURATION_BRANCH')
                            }
                            extensions {
                                cleanAfterCheckout()
                                pruneBranches()
                                relativeTargetDirectory('configuration')
                            }
                        }
                        git {
                            remote {
                                url('$CONFIGURATION_INTERNAL_REPO')
                                branch('$CONFIGURATION_INTERNAL_BRANCH')
                                if (gitCredentialId) {
                                    credentials(gitCredentialId)
                                }
{'fraction_non_alphanumeric': 0.0748853795211411, 'fraction_numerical': 0.0015282730514518594, 'mean_word_length': 1.3554289142171565, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6630112', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1851, 'n_words': 334}