Created
June 5, 2019 18:48
-
-
Save kevinhillinger/fe0d0bf9f7b7fe5a8fabb43aa0d025cd to your computer and use it in GitHub Desktop.
Deploy container to Azure Container Registry from Azure DevOps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Docker | |
| # Build and push an image to Azure Container Registry | |
| # https://docs.microsoft.com/azure/devops/pipelines/languages/docker | |
| trigger: | |
| - master | |
| resources: | |
| - repo: self | |
| variables: | |
| # Container registry service connection established during pipeline creation | |
| dockerRegistryServiceConnection: '<guid of service connection>' | |
| imageRepository: '$(Build.repository.name)' | |
| containerRegistry: '<container registry server>' | |
| dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile' | |
| tag: '$(Build.BuildId)' | |
| latestTag: 'latest' | |
| # Agent VM image name | |
| vmImageName: 'ubuntu-latest' | |
| stages: | |
| - stage: Build | |
| displayName: Build and push stage | |
| jobs: | |
| - job: Build | |
| displayName: Build job | |
| pool: | |
| vmImage: $(vmImageName) | |
| steps: | |
| - task: Docker@2 | |
| displayName: Build and push an image to container registry | |
| inputs: | |
| command: buildAndPush | |
| repository: $(imageRepository) | |
| dockerfile: $(dockerfilePath) | |
| containerRegistry: $(dockerRegistryServiceConnection) | |
| tags: | | |
| $(tag) | |
| $(latestTag) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # this task is only available in build pipeline definition | |
| # https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/kubernetes?view=azure-devops | |
| variables: | |
| azureSubscriptionEndpoint: <guid or name of endpoint> | |
| azureContainerRegistry: <container registry server> | |
| azureResourceGroup: <resource group name> | |
| kubernetesCluster: <cluster name> | |
| steps: | |
| - task: Kubernetes@1 | |
| displayName: kubectl apply | |
| inputs: | |
| connectionType: Azure Resource Manager | |
| azureSubscriptionEndpoint: $(azureSubscriptionEndpoint) | |
| azureResourceGroup: $(azureResourceGroup) | |
| kubernetesCluster: $(kubernetesCluster) | |
| command: apply | |
| arguments: -f mhc-aks.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment