Jenkinsfile.custom 1.46 KiB
@Library('deploy-conf') _
node() {
    try {
        String ANSI_GREEN = "\u001B[32m"
        String ANSI_NORMAL = "\u001B[0m"
        String ANSI_BOLD = "\u001B[1m"
        String ANSI_RED = "\u001B[31m"
        String ANSI_YELLOW = "\u001B[33m"
        stage('checkout public repo') {
            cleanWs()
            checkout scm
        ansiColor('xterm') {    
            stage('deploy custom changes'){
                values = [:]
                currentWs = sh(returnStdout: true, script: 'pwd').trim()
                envDir = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-3].trim()
                module = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-2].trim()
                jobName = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-1].trim()
                ansiblePlaybook = "${currentWs}/ansible/sunbird-auth-deploy.yml"
                ansibleExtraArgs = "--extra-vars \"host=keycloak\" --tags custom --vault-password-file  /var/lib/jenkins/secrets/vault-pass"
                values.put('currentWs', currentWs)
                values.put('env', envDir)
                values.put('module', module)
                values.put('jobName', jobName)
                values.put('ansiblePlaybook', ansiblePlaybook)
                values.put('ansibleExtraArgs', ansibleExtraArgs)
                println values
                ansible_playbook_run(values)
    catch (err) {
        throw err