Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (61 sloc) 2.3 KB
# 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
You can’t perform that action at this time.