This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
azure-pipelines.yml
86 lines (75 loc) · 2.63 KB
/
azure-pipelines.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
trigger:
- master
pool:
vmImage: 'Ubuntu-16.04'
jobs:
- job: Build
strategy:
matrix:
Kubernetes1.14:
K8S_NODE_IMAGE: 'v1.14.10'
Kubernetes1.15:
K8S_NODE_IMAGE: 'v1.15.7'
PUBLISH: 'true'
Kubernetes1.16:
K8S_NODE_IMAGE: 'v1.16.4'
Kubernetes1.17:
K8S_NODE_IMAGE: 'v1.17.0'
maxParallel: 4
steps:
# Cache the docker image file
- task: CacheBeta@0
inputs:
key: go-cache | go.sum
path: ".gocache"
restoreKeys: go-cache
displayName: Cache go mod cache
# Cache the docker image file
- task: CacheBeta@0
inputs:
key: docker-image | .devcontainer/**
path: ".dockercache"
restoreKeys: docker-image
cacheHitVar: DOCKER_CACHE_HIT
displayName: Cache docker layers
- script: |
bash -f ./ci.sh
displayName: 'Run CI'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/TEST-*.xml'
mergeTestResults: true
failTaskOnFailedTests: true
publishRunAttachments: true
displayName: Publish test results
- task: Docker@2
condition: succeeded()
inputs:
containerRegistry: 'my-registry'
command: 'login'
displayName: docker login
- task: Bash@3
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['PUBLISH'], 'true'))
inputs:
targetType: 'inline'
script: |
# Write your commands here
docker tag initcontainer:latest-${BUILD_BUILDNUMBER} my-registry.azurecr.io/initcontainer:latest-${BUILD_BUILDNUMBER}
docker tag initcontainer:latest-${BUILD_BUILDNUMBER} my-registry.azurecr.io/initcontainer:latest
docker push my-registry.azurecr.io/initcontainer:latest-${BUILD_BUILDNUMBER}
docker push my-registry.azurecr.io/initcontainer:latest
displayName: docker tag and push master
- task: Bash@3
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'), eq(variables['PUBLISH'], 'true'))
inputs:
targetType: 'inline'
script: |
# Write your commands here
# Remove beginning of branch name
BRANCH_NAME=${SYSTEM_PULLREQUEST_SOURCEBRANCH//refs\/heads\//}
# Replace all / with -
BRANCH_NAME=${BRANCH_NAME//\//-}
docker tag initcontainer:latest-${BUILD_BUILDNUMBER} my-registry.azurecr.io/initcontainer:pr-${BRANCH_NAME}-${BUILD_BUILDNUMBER}
docker push my-registry.azurecr.io/initcontainer:pr-${BRANCH_NAME}-${BUILD_BUILDNUMBER}
displayName: docker tag and push PR build