-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathJenkinsfile
47 lines (36 loc) · 1.26 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
pipeline {
agent any
stages {
stage('Clone Repo'){
steps{
git 'https://github.com/ishrivatsa/terraform-vault-jenkins.git'
}
}
stage('Install TF Dependencies') {
steps{
sh "sudo apt install wget zip python-pip -y"
sh "curl -o terraform.zip https://releases.hashicorp.com/terraform/0.12.5/terraform_0.12.5_linux_amd64.zip"
sh "unzip terraform.zip"
sh "sudo mv terraform /usr/bin"
sh "rm -rf terraform.zip"
}
}
stage('Deploy') {
steps {
sh "sudo apt install wget zip python-pip -y"
sh "curl -o vault.zip https://releases.hashicorp.com/vault/1.2.3/vault_1.2.3_linux_amd64.zip"
sh "unzip vault.zip"
sh "sudo mv vault /usr/bin"
sh "rm -rf vault.zip"
withCredentials([[$class: 'VaultTokenCredentialBinding', addrVariable: 'VAULT_ADDR', credentialsId: 'github-creds', tokenVariable: 'GITHUB', vaultAddr: 'http://0.0.0.0:8205']]) {
sh '''
export TF_VAR_vault_token=$(vault login -field=token token=$GITHUB)
cd terraform_templates/
terraform init
terraform apply --auto-approve
'''
}
}
}
}
}