-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathJenkinsfile
More file actions
66 lines (59 loc) · 1.75 KB
/
Jenkinsfile
File metadata and controls
66 lines (59 loc) · 1.75 KB
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
59
60
61
62
63
64
65
66
pipeline {
agent {
label 'built-in'
}
options {
ansiColor('xterm')
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')
parallelsAlwaysFailFast()
timestamps()
}
triggers {
GenericTrigger(
genericVariables: [
[key: 'actor', value: '$.repository.owner.name'],
[key: 'branch', value: '$.ref']
],
token: 'ansible-1',
printContributedVariables: true,
printPostContent: false,
silentResponse: false,
regexpFilterText: '$branch',
regexpFilterExpression: 'refs/heads/' + BRANCH_NAME
)
}
stages {
stage('Pre-requisities') {
steps {
sh "env"
}
}
stage('Approve Update') {
steps {
script {
if( env.BRANCH_NAME == 'master' ){
timeout(time: 3, unit: 'DAYS') {
input(message: 'Update Image?', parameters: [
[$class: 'TextParameterDefinition', defaultValue: env.BRANCH_NAME, description: '', name: 'env'],
])
}
} else {
echo "Environment ${params.environment} does not require an approval"
}
}
}
}
stage('deploy ansible') {
steps {
withCredentials([string(credentialsId: 'vault-credentials', variable: 'password')]) {
sh ("echo $password > vault-password.txt ; ansible-playbook playbooks/vault-1.yml --vault-password vault-password.txt")
}
}
}
}
post {
always {
sh "rm -f vault-password.txt"
}
}
}