-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
70 lines (62 loc) · 1.59 KB
/
azure-pipelines.yml
File metadata and controls
70 lines (62 loc) · 1.59 KB
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
#
# Azure Pipeline - Generic build defintion for containerized apps
# Build as Docker container image and push to ACR
# Ben C, 2019
#
trigger:
branches:
include: [ master ]
pool:
name: Hosted Ubuntu 1604
#
# NOTE! The shared-secrets variable group must be pre-created and populated
# - Expected variables: acr-password, dockerhub-password
#
variables:
- group: shared-secrets
- name: app-name
value: nodejs-demoapp
- name: acr-name
value: bcdemo
- name: dockerhub-name
value: bencuk
- name: docker-file
value: Dockerfile
steps:
#
# Run unit tests with Mocha
#
- bash: |
npm install
npm run tests-junit
displayName: 'Run unit tests with Mocha'
#
# Publish test results
#
- task: PublishTestResults@2
inputs:
testResultsFormat: JUnit
testResultsFiles: 'test-results.xml'
searchFolder: '$(System.DefaultWorkingDirectory)'
condition: always()
displayName: 'Publish test results'
#
# Run Docker build
#
- bash: |
docker build . -f $(docker-file) -t $(dockerhub-name)/$(app-name):latest -t $(acr-name).azurecr.io/apps/$(app-name):latest -t $(acr-name).azurecr.io/apps/$(app-name):$(Build.BuildNumber)
displayName: 'Build app as container image'
#
# Push latest + tagged images to ACR
#
- bash: |
docker login $(acr-name).azurecr.io -u $(acr-name) -p $(acr-password)
docker push $(acr-name).azurecr.io/apps/$(app-name)
displayName: 'Push image to ACR'
#
# Push latest to Dockerhub
#
- bash: |
docker login -u $(dockerhub-name) -p $(dockerhub-password)
docker push $(dockerhub-name)/$(app-name):latest
displayName: 'Push image to Dockerhub'