-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsfile
56 lines (52 loc) · 1.55 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
pipeline {
//agent any
agent {
docker {
image 'ansible:2.9.11'
args '-u 0:0'
}
}
environment {
GIT_BRANCH='dev'
GIT_URL='https://github.com/jtom38/ansible.git'
ANSIBLE_VAULT_FILE='./.ansible_vault'
ANSIBLE_HOST_KEY_CHECKING='False'
}
stages {
stage('Checkout-Code') {
steps {
sh ''' #!/bin/bash
echo "Checking where we start"
pwd
echo "Checking current dir"
ls
echo "Checking active user"
whoami
echo "Cleaning up old builds"
rm ./gitAnsible -f -r
git clone ${GIT_URL} gitAnsible
cd ./gitAnsible
git checkout ${GIT_BRANCH}
'''
}
}
stage('Get-Galaxy-Requirements'){
steps {
sh '''#!/bin/bash
pwd
cd ./gitAnsible
ansible-galaxy install -r requirements.yml
'''
}
}
stage('Run-Linux-Common') {
steps {
withCredentials([file(credentialsId: 'ansible-vault-file', variable: 'FILE')]) {
sh '''#!/bin/bash
ansible-playbook ./gitAnsible/playbook/linux/common.yml -i ./gitAnsible/inventory --vault-password-file $FILE
'''
}
}
}
}
}