-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
55 lines (50 loc) · 1.12 KB
/
Jenkinsfile
File metadata and controls
55 lines (50 loc) · 1.12 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
pipeline {
agent any
environment {
AZ = credentials('Azure Service Principal')
tfvars_file = credentials('tfvars')
}
tools {
terraform 'terraform'
}
stages {
stage('SCM') {
when { changeset "terraform/*"}
steps {
script {
checkout scm
}
}
}
stage('SonarQube Analysis') {
when { changeset "terraform/*"}
steps {
script {
def scannerHome = tool 'sonarscanner'
withSonarQubeEnv('sonarserver') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
}
stage("Quality Gate") {
when { changeset "terraform/*"}
steps {
waitForQualityGate abortPipeline: true
}
}
stage('Terraform') {
when { changeset "terraform/*"}
steps {
script {
dir("terraform") {
sh 'az login --service-principal -u $AZ_CLIENT_ID -p $AZ_CLIENT_SECRET -t $AZ_TENANT_ID'
sh 'terraform init'
sh 'terraform plan --var-file=$tfvars_file'
//sh 'terraform apply -auto-approve'
}
}
}
}
}
}