forked from Azure/azch-captureorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.dockerhub.yml
33 lines (27 loc) · 1.31 KB
/
azure-pipelines.dockerhub.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
# Docker image
# Build a Docker image to deploy, run, or push to a container registry.
# Add steps that use Docker Compose, tag images, push to a registry, run an image, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
name: $(build.sourceBranchName)-$(Date:yyyyMMdd)$(Rev:.r)
pool:
vmImage: 'Ubuntu 16.04'
variables:
- group: azch-docker
- name: imageName
value: '$(dockerId)/captureorder'
steps:
- script: docker build -f Dockerfile -t $(imageName) .
displayName: 'docker build'
# Only do a docker login and docker push if we're on the master branch
# There is no need to login and push for a pull request, since we don't have end to end testing now
- script: docker login -u $(dockerId) -p $(dockerPassword)
displayName: 'docker login'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- script: docker push $(imageName)
displayName: 'docker push latest if this is the master branch'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- script: |
docker tag $(imageName) $(imageName):$(build.buildNumber)
docker push $(imageName):$(build.buildNumber)
displayName: 'docker push with build number'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))