forked from dicdiksha/fork-sunbird-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
kubernetes/pipelines/bootstrap_minimal/Jenkinsfile.namespace
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@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') { | ||
folder = new File("$WORKSPACE/.git") | ||
if (folder.exists()) | ||
{ | ||
println "Found .git folder. Clearing it.." | ||
sh'git clean -fxd' | ||
} | ||
checkout scm | ||
} | ||
|
||
stage('deploy') { | ||
values = [:] | ||
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() | ||
currentWs = sh(returnStdout: true, script: 'pwd').trim() | ||
ansiblePlaybook = "$currentWs/ansible/create_namespace.yml" | ||
ansibleExtraArgs = "--vault-password-file /var/lib/jenkins/secrets/vault-pass -v" | ||
values.put('currentWs', currentWs) | ||
values.put('env', envDir) | ||
values.put('module', module) | ||
values.put('ansiblePlaybook', ansiblePlaybook) | ||
values.put('ansibleExtraArgs', ansibleExtraArgs) | ||
ansible_playbook_run(values) | ||
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}" | ||
} | ||
summary() | ||
} | ||
catch (err) { | ||
currentBuild.result = "FAILURE" | ||
throw err | ||
} | ||
finally { | ||
slack_notify(currentBuild.result) | ||
email_notify() | ||
} | ||
} |