-
Notifications
You must be signed in to change notification settings - Fork 14
/
azure-pipelines.yml
66 lines (61 loc) · 2.3 KB
/
azure-pipelines.yml
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
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
containers:
- container: 'aks_module_test'
image: terraform-azure-reference/aks-module-tests:$(tag)
endpoint: jcorioland_acr
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'a0d4d283-d17d-4c9f-9154-c5c3be4f24c5'
imageRepository: 'terraform-azure-reference/aks-module-tests'
containerRegistry: 'jcorioland.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build Container Image and Run Tests
jobs:
- job: Build
displayName: Build Container Image and Run Tests
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build Tests Container Image
inputs:
command: build
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- script: |
mkdir ./test_output
docker run \
-e SERVICE_PRINCIPAL_CLIENT_ID=$(SERVICE_PRINCIPAL_CLIENT_ID) \
-e SERVICE_PRINCIPAL_CLIENT_SECRET=$(SERVICE_PRINCIPAL_CLIENT_SECRET) \
-e ARM_SUBSCRIPTION_ID=$(ARM_SUBSCRIPTION_ID) \
-e ARM_CLIENT_ID=$(ARM_CLIENT_ID) \
-e ARM_CLIENT_SECRET=$(ARM_CLIENT_SECRET) \
-e ARM_TENANT_ID=$(ARM_TENANT_ID) \
-v $(System.DefaultWorkingDirectory)/test_output:/go/src/aks-module/test_output \
$(containerRegistry)/$(imageRepository):$(tag)
displayName: Run tests in container
env:
SERVICE_PRINCIPAL_CLIENT_ID: $(SERVICE_PRINCIPAL_CLIENT_ID)
SERVICE_PRINCIPAL_CLIENT_SECRET: $(SERVICE_PRINCIPAL_CLIENT_SECRET)
ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)
ARM_CLIENT_ID: $(ARM_CLIENT_ID)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
ARM_TENANT_ID: $(ARM_TENANT_ID)
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/report.xml'
failTaskOnFailedTests: true