Skip to content

Commit c348f2e

Browse files
authored
Add build context support for ADO pipelines (#510)
1 parent 20f270b commit c348f2e

6 files changed

Lines changed: 60 additions & 42 deletions

File tree

pkg/fixtures/workflows/azurepipelines/kustomize/.pipelines/azure-kubernetes-service.yaml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
# Azure Kubernetes Service (AKS) pipeline with Kustomize
2-
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service cluster
3-
4-
variables:
5-
armServiceConnection: testserviceconnection
6-
azureContainerRegistry: myacr.acr.io
7-
containerName: myapp
8-
acrRg: myrg
9-
clusterRg: myrg
10-
clusterName: testcluster
11-
kustomizePath: ./overlays/production
12-
namespace: default
13-
tag: "$(Build.BuildId)"
14-
vmImageName: "ubuntu-latest"
15-
16-
trigger:
17-
- main
18-
19-
name: Build and deploy an app to AKS
1+
# Azure Kubernetes Service (AKS) pipeline with Kustomize
2+
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service cluster
3+
4+
variables:
5+
armServiceConnection: testserviceconnection
6+
azureContainerRegistry: myacr.acr.io
7+
containerName: myapp
8+
acrRg: myrg
9+
clusterRg: myrg
10+
clusterName: testcluster
11+
kustomizePath: ./overlays/production
12+
namespace: default
13+
buildContextPath: .
14+
tag: "$(Build.BuildId)"
15+
vmImageName: "ubuntu-latest"
16+
17+
trigger:
18+
- main
19+
20+
name: Build and deploy an app to AKS
2021

2122
stages:
2223
- stage: BuildAndPush
@@ -34,7 +35,7 @@ stages:
3435
scriptType: "bash"
3536
scriptLocation: "inlineScript"
3637
inlineScript: |
37-
az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 .
38+
az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 $(buildContextPath)
3839
arguments: "$(azureContainerRegistry) $(containerName) $(tag) $(acrRg)"
3940

4041
- stage: Deploy

pkg/fixtures/workflows/azurepipelines/manifests/.pipelines/azure-kubernetes-service.yaml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
# Azure Kubernetes Service pipeline
2-
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service cluster
3-
4-
variables:
5-
armServiceConnection: testserviceconnection
6-
azureContainerRegistry: myacr.acr.io
7-
containerName: myapp
8-
clusterRg: myrg
9-
acrRg: myrg
10-
clusterName: testcluster
11-
manifestPath: ./manifests
12-
namespace: default
13-
tag: "$(Build.BuildId)"
14-
vmImageName: "ubuntu-latest"
15-
16-
name: Build and deploy an app to AKS
17-
18-
trigger:
19-
- main
1+
# Azure Kubernetes Service pipeline
2+
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service cluster
3+
4+
variables:
5+
armServiceConnection: testserviceconnection
6+
azureContainerRegistry: myacr.acr.io
7+
containerName: myapp
8+
clusterRg: myrg
9+
acrRg: myrg
10+
clusterName: testcluster
11+
manifestPath: ./manifests
12+
namespace: default
13+
buildContextPath: .
14+
tag: "$(Build.BuildId)"
15+
vmImageName: "ubuntu-latest"
16+
17+
name: Build and deploy an app to AKS
18+
19+
trigger:
20+
- main
2021

2122
stages:
2223
- stage: BuildAndPush
@@ -34,7 +35,7 @@ stages:
3435
scriptType: "bash"
3536
scriptLocation: "inlineScript"
3637
inlineScript: |
37-
az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 .
38+
az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 $(buildContextPath)
3839
arguments: "$(azureContainerRegistry) $(containerName) $(tag) $(acrRg)"
3940

4041
- stage: Deploy

template/azurePipelines/kustomize/.pipelines/azure-kubernetes-service.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ variables:
1010
clusterName: {{ .Config.GetVariableValue "CLUSTERNAME" }}
1111
kustomizePath: {{ .Config.GetVariableValue "KUSTOMIZEPATH" }}
1212
namespace: {{ .Config.GetVariableValue "NAMESPACE" }}
13+
buildContextPath: {{ .Config.GetVariableValue "BUILDCONTEXTPATH" }}
1314
tag: "$(Build.BuildId)"
1415
vmImageName: "ubuntu-latest"
1516

@@ -34,7 +35,7 @@ stages:
3435
scriptType: "bash"
3536
scriptLocation: "inlineScript"
3637
inlineScript: |
37-
az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 .
38+
az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 $(buildContextPath)
3839
arguments: "$(azureContainerRegistry) $(containerName) $(tag) $(acrRg)"
3940

4041
- stage: Deploy

template/azurePipelines/kustomize/draft.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ variables:
6363
value: "default"
6464
description: "the Kubernetes namespace"
6565
versions: ">=0.0.1"
66+
- name: "BUILDCONTEXTPATH"
67+
type: "string"
68+
kind: "dirPath"
69+
default:
70+
value: "."
71+
description: "the path to the Docker build context"
72+
versions: ">=0.0.1"

template/azurePipelines/manifests/.pipelines/azure-kubernetes-service.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ variables:
1010
clusterName: {{ .Config.GetVariableValue "CLUSTERNAME" }}
1111
manifestPath: {{ .Config.GetVariableValue "MANIFESTPATH" }}
1212
namespace: {{ .Config.GetVariableValue "NAMESPACE" }}
13+
buildContextPath: {{ .Config.GetVariableValue "BUILDCONTEXTPATH" }}
1314
tag: "$(Build.BuildId)"
1415
vmImageName: "ubuntu-latest"
1516

@@ -34,7 +35,7 @@ stages:
3435
scriptType: "bash"
3536
scriptLocation: "inlineScript"
3637
inlineScript: |
37-
az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 .
38+
az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 $(buildContextPath)
3839
arguments: "$(azureContainerRegistry) $(containerName) $(tag) $(acrRg)"
3940

4041
- stage: Deploy

template/azurePipelines/manifests/draft.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ variables:
6363
value: "default"
6464
description: "the Kubernetes namespace"
6565
versions: ">=0.0.1"
66+
- name: "BUILDCONTEXTPATH"
67+
type: "string"
68+
kind: "dirPath"
69+
default:
70+
value: "."
71+
description: "the path to the Docker build context"
72+
versions: ">=0.0.1"

0 commit comments

Comments
 (0)