-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
80 lines (73 loc) · 2.65 KB
/
build.gradle
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
plugins {
id 'base'
id "org.sonarqube" version "3.4.0.2513"
}
task build(overwrite: true, dependsOn:['test', 'tfFmt', 'tfValidate'])
task test(type:Exec) {
commandLine 'pytest'
}
sonarqube {
properties {
property "sonar.projectName", "gke-workload-identity"
property "sonar.projectKey", "DevSecOpsSamples_gke-workload-identity"
property "sonar.organization", "devsecopssamples"
// property "sonar.host.url", "http://127.0.0.1:9000"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.sources", "src"
property "sonar.python.version", "3.9"
property "sonar.coverage.jacoco.xmlReportPaths", "build/test-result.xml"
property "sonar.python.coverage.reportPaths", "build/test-coverage.xml"
property "sonar.exclusions", "build/**, gha-creds-*.json, .*sa"
property "sonar.issue.ignore.multicriteria", "e1"
property "sonar.issue.ignore.multicriteria.e1.ruleKey", "terraform:S6404"
property "sonar.issue.ignore.multicriteria.e1.resourceKey", "**/*.tf"
property "sonar.links.ci", "https://github.com/DevSecOpsSamples/gke-workload-identity/actions"
}
}
clean.doLast {
delete "${rootDir}/src/bucket-api/bucket-api.yaml"
delete "${rootDir}/src/pubsub-api/pubsub-api.yaml"
delete "${rootDir}/.pytest_cache"
delete fileTree(dir: './' , include: '**/.coverage')
delete fileTree(dir: 'src' , include: '**/*.pyc')
// delete fileTree(dir: 'src' , include: '**/__pycache__/**')
}
task tfFmt {
doLast {
exec {
println "terraform format: src/tf/*"
executable "sh"
args "-c", "terraform fmt -recursive src/tf"
}
}
}
task tfValidate {
doLast {
def dirs = ["autopilot-cluster", "standard-cluster", "workload-identity"]
for (dir in dirs ) {
def workDir = "src/tf/${dir}"
exec {
println "terraform init: ${workDir}"
executable "sh"
args "-c", "terraform -chdir='${workDir}' init"
}
exec {
println "terraform validate: ${workDir}"
executable "sh"
args "-c", "terraform -chdir='${workDir}' validate"
}
}
}
}
task tfClean {
doLast {
def dirs = ["autopilot-cluster", "standard-cluster", "workload-identity"]
for (dir in dirs ) {
def workDir = "src/tf/${dir}"
println "clean terraform: ${workDir}/.terraform"
delete "${workDir}/.terraform"
// fileTree(dir: workDir , include: '.terraform')
}
}
}