-
Notifications
You must be signed in to change notification settings - Fork 18
/
Jenkinsfile_DockerPush
37 lines (37 loc) · 1.41 KB
/
Jenkinsfile_DockerPush
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
@Library('deploy-conf') _
node(){
try {
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('Artifact Upload') {
values = docker_params()
if(params.artifact_source == "ArtifactRepo") {
currentWs = sh(returnStdout: true, script: 'pwd').trim()
ansiblePlaybook = "$currentWs/ansible/docker_image_push.yml"
ansibleExtraArgs = "--extra-vars \"hub_org=${hub_org} image_name=${values.image_name} image_tag=${values.image_tag}\" --vault-password-file /var/lib/jenkins/secrets/vault-pass"
values.put('currentWs', currentWs)
values.put('ansiblePlaybook', ansiblePlaybook)
values.put('ansibleExtraArgs', ansibleExtraArgs)
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
}
archiveArtifacts 'metadata.json'
currentBuild.description = "Image: ${values.image_tag}, Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}