forked from stacksimplify/azure-devops-github-acr-aks-app1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03-custom1-pipeline-buildandpush-to-acr-and-publish-artifacts.yml
59 lines (54 loc) · 2.15 KB
/
03-custom1-pipeline-buildandpush-to-acr-and-publish-artifacts.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
# 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: 'cf9f2bef-6696-4dea-9fa3-580d9b5cab9d'
imageRepository: 'custom1aksnginxapp1'
containerRegistry: 'aksdevopsacr.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
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)
## Publish Artifacts pipeline code in addition to Build and Push
- bash: echo Contents in System Default Working Directory; ls -R $(System.DefaultWorkingDirectory)
- bash: echo Before copying Contents in Build Artifact Directory; ls -R $(Build.ArtifactStagingDirectory)
# Task-2: Copy files (Copy files from a source folder to target folder)
# Source Directory: $(System.DefaultWorkingDirectory)/kube-manifests
# Target Directory: $(Build.ArtifactStagingDirectory)
- task: CopyFiles@2
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/kube-manifests'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
OverWrite: true
# List files from Build Artifact Staging Directory - After Copy
- bash: echo After copying to Build Artifact Directory; ls -R $(Build.ArtifactStagingDirectory)
# Task-3: Publish build artifacts (Publish build to Azure Pipelines)
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'kube-manifests'
publishLocation: 'Container'