1
+ # Docker
2
+ # Build and push an image to Azure Container Registry
3
+ # https://docs.microsoft.com/azure/devops/pipelines/languages/docker
4
+
5
+ trigger :
6
+ - master
7
+
8
+ resources :
9
+ - repo : self
10
+
11
+ variables :
12
+ # Container registry service connection established during pipeline creation
13
+ dockerRegistryServiceConnection : ' cf9f2bef-6696-4dea-9fa3-580d9b5cab9d'
14
+ imageRepository : ' custom1aksnginxapp1'
15
+ containerRegistry : ' aksdevopsacr.azurecr.io'
16
+ dockerfilePath : ' $(Build.SourcesDirectory)/Dockerfile'
17
+ tag : ' $(Build.BuildId)'
18
+
19
+ # Agent VM image name
20
+ vmImageName : ' ubuntu-latest'
21
+
22
+ stages :
23
+ - stage : Build
24
+ displayName : Build and push stage
25
+ jobs :
26
+ - job : Build
27
+ displayName : Build
28
+ pool :
29
+ vmImage : $(vmImageName)
30
+ steps :
31
+ - task : Docker@2
32
+ displayName : Build and push an image to container registry
33
+ inputs :
34
+ command : buildAndPush
35
+ repository : $(imageRepository)
36
+ dockerfile : $(dockerfilePath)
37
+ containerRegistry : $(dockerRegistryServiceConnection)
38
+ tags : |
39
+ $(tag)
40
+ # # Publish Artifacts pipeline code in addition to Build and Push
41
+ - bash : echo Contents in System Default Working Directory; ls -R $(System.DefaultWorkingDirectory)
42
+ - bash : echo Before copying Contents in Build Artifact Directory; ls -R $(Build.ArtifactStagingDirectory)
43
+ # Task-2: Copy files (Copy files from a source folder to target folder)
44
+ # Source Directory: $(System.DefaultWorkingDirectory)/kube-manifests
45
+ # Target Directory: $(Build.ArtifactStagingDirectory)
46
+ - task : CopyFiles@2
47
+ inputs :
48
+ SourceFolder : ' $(System.DefaultWorkingDirectory)/kube-manifests'
49
+ Contents : ' **'
50
+ TargetFolder : ' $(Build.ArtifactStagingDirectory)'
51
+ OverWrite : true
52
+ # Task-3: Publish build artifacts (Publish build to Azure Pipelines)
53
+ - task : PublishBuildArtifacts@1
54
+ inputs :
55
+ PathtoPublish : ' $(Build.ArtifactStagingDirectory)'
56
+ ArtifactName : ' kube-manifests'
57
+ publishLocation : ' Container'
0 commit comments