node {
    cleanWs()
}
node {
    properties([
        parameters([
            string(name: 'INIT_CODE', defaultValue: '', description: 'Password is required to start the server setup process.')
        ])
    ])
    stage('check_input') {
        if (env.INIT_CODE != "this is setup password 123456") {
            error("Aborting the build - passwords do not match.")
        }
    }
    stage('checkout') {
        checkout ([ \
            $class: 'GitSCM', \
            branches: [[name: '*/master']], \
            doGenerateSubmoduleConfigurations: false, \
            extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'devops'], [ $class: 'ScmName', name: 'devops' ], [$class: 'CloneOption', depth: 1, shallow: true]], \
            submoduleCfg: [], \
            userRemoteConfigs: [[credentialsId: '9af2bd5f-a2b4-4470-8356-64e9a5576c0a', url: 'git@github.com:BigscreenVR/devops.git']] \
        ])
    }
}
node {
    stage("terraform_deploy_redis_cluster") {
        sh '''#!/bin/bash
. `pwd`/devops/Jenkins/server_builder_v6.sh
NETWORK="dev"
init_network_config_files $NETWORK
terraform_deploy_network_databases $NETWORK
'''
    }
}