Last active
February 25, 2020 15:26
-
-
Save acraven/0608ff1f68bbded60552f126c0f5c088 to your computer and use it in GitHub Desktop.
Hacked azure-pipelines.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Include branch name to prevent PR builds consuming version numbers from master builds | |
name: $(Build.SourceBranchName)-1.0$(Rev:.r) | |
trigger: | |
batch: false | |
branches: | |
include: | |
- master | |
paths: | |
exclude: | |
- README.md | |
pool: | |
vmImage: 'Ubuntu-16.04' | |
variables: | |
azureSubscriptionEndpoint: {SUBSCRIPTION} | |
azureContainerRegistry: {REGISTRY} | |
repositoryName: '$(azureContainerRegistry)/{SERVICE}' | |
steps: | |
- script: | | |
if [ "$(Build.SourceBranchName)" == "master" ]; then | |
echo "Versioning for master build" | |
version=$(echo "$(Build.BuildNumber)" | cut -d "-" -f 2) | |
echo "##vso[task.setvariable variable=version]$version" | |
echo "##vso[task.setvariable variable=imageName]$(repositoryName):$version" | |
elif [ -n "$(System.PullRequest.PullRequestId)" ]; then | |
echo "Versioning for PR build" | |
version=0.$(System.PullRequest.PullRequestId).$(build.buildId) | |
echo "##vso[task.setvariable variable=version]$version" | |
echo "##vso[task.setvariable variable=imageName]$(repositoryName):$version-pr" | |
else | |
echo "Branch is not for master nor a pull request" | |
exit 1 | |
fi | |
displayName: 'Set version and imageName variables' | |
- script: docker build --build-arg version=$(version) -t $(imageName) package | |
displayName: 'docker build' | |
- task: Docker@1 | |
displayName: 'docker push' | |
inputs: | |
command: push | |
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint) | |
azureContainerRegistry: $(azureContainerRegistry) | |
imageName: $(imageName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment