Newer
Older
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
trigger:
branches:
include:
- kuber-migration
paths:
exclude:
- README.md
- .gitignore
pool:
name: Hosted Ubuntu 1604
demands: maven
variables:
buildMavenModules: legal-core,provider/legal-gcp
dockerDir: provider/legal-gcp/docker
imageName: os-legal-app
deploymentDir: provider/legal-gcp/kubernetes/deployments
deploymentFile: deployment-os-legal-service.yml
mavenSettings: ./maven/settings.xml
integrationTestCorePom: testing/legal-test-core/pom.xml
integrationTestGcpPom: testing/legal-test-gcp/pom.xml
steps:
- task: DownloadSecureFile@1
name: gcrKey
inputs:
secureFile: cicd-push-image-to-cr-keyfile.json
- task: DownloadSecureFile@1
name: kuberConfig
inputs:
secureFile: kubeconfig
- task: DownloadSecureFile@1
name: gac
inputs:
secureFile: opendes-datafier-126f1340d475.json
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
options: '--settings $(mavenSettings) -DVSTS_FEED_TOKEN=$(VSTS_FEED_TOKEN) -P legal-core install'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
options: '--settings $(mavenSettings) -DVSTS_FEED_TOKEN=$(VSTS_FEED_TOKEN) -P legal-gcp -DskipTests package'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
- bash: |
#!/bin/bash
set -e
pushd $(dockerDir)
docker-compose build $(imageName)
echo 'Image done.'
cat $(gcrKey.secureFilePath) | docker login -u _json_key --password-stdin https://gcr.io
echo 'Login done.'
docker push gcr.io/opendes/$(imageName)
echo 'Push done.'
popd
pushd $(deploymentDir)
kubectl --kubeconfig $(kuberConfig.secureFilePath) delete -f $(deploymentFile)
kubectl --kubeconfig $(kuberConfig.secureFilePath) apply -f $(deploymentFile)
popd
attempt_counter=0
max_attempts=60
max_attempts=120
until [[ $(curl --head --write-out %{http_code} $(LEGAL_READINESS_URL) --silent -o /dev/null --fail) -eq 401 ]]; do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "Service is not available, integraton tests are skipped"
exit 1
fi
printf '.'
attempt_counter=$(($attempt_counter+1))
sleep 2
done
- task: Maven@3
inputs:
mavenPomFile: '$(integrationTestCorePom)'
options: '--settings $(mavenSettings) -DVSTS_FEED_TOKEN=$(VSTS_FEED_TOKEN) install'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
- task: Maven@3
inputs:
mavenPomFile: '$(integrationTestGcpPom)'
options: '--settings $(mavenSettings) -DargLine="-DGOOGLE_APPLICATION_CREDENTIALS=$(gac.secureFilePath)" -DSKIP_HTTP_TESTS=SKIP_HTTP_TESTS -Dsurefire.useFile=false -DVSTS_FEED_TOKEN=$(VSTS_FEED_TOKEN) -DINTEGRATION_TESTER=$(INTEGRATION_TESTER) -DNO_DATA_ACCESS_TESTER=$(NO_DATA_ACCESS_TESTER) -DHOST_URL=$(HOST_URL) -DINTEGRATION_TEST_AUDIENCE=$(INTEGRATION_TEST_AUDIENCE) -DMY_TENANT=$(MY_TENANT) -DMY_TENANT_PROJECT=$(MY_TENANT_PROJECT) compile'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false