Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up CI with Azure Pipelines #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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

trigger:
- master
- development
- feature/*
- bugfix/*
- hotfix/*

pr:
- master
- develop

pool:
vmImage: 'Ubuntu-16.04'

variables:
tagshelfRegistry: 'docker.tagshelf.io'
imageName: 'tagshelfsrl/duckling'

steps:
# Builds the docker image for all allowed branches
- script: docker build -f Dockerfile -t $(imageName) .
displayName: 'docker build'
# Tags builded image with the "latest" tag if its "master" branch and push
- script: docker tag $(imageName) "$(tagshelfRegistry)/$(imageName):latest"
displayName: 'docker tag master as latest'
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
- script: |
docker login -u $(tagshelfRegistryUser) -p $(tagshelfRegistryPass) $(tagshelfRegistry)
docker push $(tagshelfRegistry)/$(imageName):latest
displayName: 'docker push master as latest'
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
# Tags builded image with the "development" tag if its "development" branch and push
- script: docker tag $(imageName) "$(tagshelfRegistry)/$(imageName):$(build.SourceBranchName)"
displayName: 'docker tag development'
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'development'))
- script: |
docker login -u $(tagshelfRegistryUser) -p $(tagshelfRegistryPass) $(tagshelfRegistry)
docker push $(tagshelfRegistry)/$(imageName):$(build.SourceBranchName)
displayName: 'docker push development'
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'development'))
# Tags builded image with the branchName_commitHash tag if its "master" or "development" branch and push
- script: docker tag $(imageName) "$(tagshelfRegistry)/$(imageName):$(build.SourceBranchName)_$(build.SourceVersion)"
displayName: 'docker tag branch_version'
condition: and(succeeded(), or(eq(variables['Build.SourceBranchName'], 'master'), eq(variables['Build.SourceBranchName'], 'development')))
- script: |
docker login -u $(tagshelfRegistryUser) -p $(tagshelfRegistryPass) $(tagshelfRegistry)
docker push (tagshelfRegistry)/$(imageName):$(build.SourceBranchName)_$(build.SourceVersion)
displayName: 'docker push buikd'
condition: and(succeeded(), or(eq(variables['Build.SourceBranchName'], 'master'), eq(variables['Build.SourceBranchName'], 'development')))