-
Notifications
You must be signed in to change notification settings - Fork 372
/
Copy pathJenkinsfile
58 lines (57 loc) · 2.54 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@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
}
ansiColor('xterm') {
stage('get artifact') {
values = lp_dp_params()
currentWs = sh(returnStdout: true, script: 'pwd').trim()
artifact = values.artifact_name + ":" + values.artifact_version
values.put('currentWs', currentWs)
values.put('artifact', artifact)
artifact_download(values)
}
stage('deploy artifact') {
sh """
unzip ${artifact}
"""
sh """
rm -rf script_repo
git clone ${params.script_repo} -b ${params.script_repo_branch_or_tag} script_repo
"""
ansiblePlaybook = "${currentWs}/ansible/cassandra-deploy.yml"
ansibleExtraArgs = "--extra-vars \"script_location=${currentWs}/script_repo/sunbird-cassandra-migration/cassandra-migration/src/main/resources/db/migration/cassandra/${params.cassandra_keyspace_to_migrate} cassandra_keyspace_to_migrate=${params.cassandra_keyspace_to_migrate}\" --vault-password-file /var/lib/jenkins/secrets/vault-pass -v"
values.put('ansiblePlaybook', ansiblePlaybook)
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
archiveArtifacts artifacts: "${artifact}", fingerprint: true, onlyIfSuccessful: true
archiveArtifacts artifacts: 'metadata.json', onlyIfSuccessful: true
currentBuild.description = "Artifact: ${values.artifact_version}, Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
summary()
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}