Skip to content

Instantly share code, notes, and snippets.

@chetanku
Last active May 13, 2024 15:54
Show Gist options
  • Save chetanku/c51526d7322989ba5a62f186df261cd3 to your computer and use it in GitHub Desktop.
Save chetanku/c51526d7322989ba5a62f186df261cd3 to your computer and use it in GitHub Desktop.
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
major: 2
minor: 0
stages:
# Versioning master branch builds
- stage:
displayName: Build_Master_Version_Number
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
jobs:
- job: Build_Master_Version_Number
variables:
patch: $[counter(variables['minor'], 0)]
steps:
- bash: |
echo "##vso[build.updatebuildnumber]$(major).$(minor).$(patch)"
name: SetMasterBuildName
# Versioning feature branch and PR builds
- stage:
displayName: Build_Branch_Version_Number
condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
jobs:
- job: Build_Branch_Version_Number
variables:
prpatch: $[counter(variables['system.pullrequest.pullrequestid'], 0)]
brpatch: $[counter(variables['build.sourcebranchname'], 0)]
steps:
- bash: |
echo "##vso[build.updatebuildnumber]$(major).$(minor)-PullRequest.$(prpatch)"
condition: eq(variables['Build.Reason'], 'PullRequest')
name: SetPRBuildName
- bash: |
echo "##vso[build.updatebuildnumber]$(major).$(minor)-$(Build.SourceBranchName).$(brpatch)"
condition: ne(variables['Build.Reason'], 'PullRequest')
name: SetBranchBuildName
# Stage for building your application
- stage: Build_Steps
displayName: Build_Steps
condition: always()
jobs:
- job: Build_Steps
displayName: Build_Steps
steps:
- script: echo Hello, world!
name: 'Run_a_one_line_script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
name: 'Run_a_multi_line_cript'
@githubabhinav1
Copy link

Thank You for this !! It is very helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment