Skip to content

Instantly share code, notes, and snippets.

@mirontoli
Created March 31, 2021 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirontoli/d06bc686aafe8a4642998b45dcd81a85 to your computer and use it in GitHub Desktop.
Save mirontoli/d06bc686aafe8a4642998b45dcd81a85 to your computer and use it in GitHub Desktop.
git config --global user.email "azuredevops@microsoft.com"
git config --global user.name "Azure DevOps"
REPO="$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_git/$(Build.Repository.Name)"
EXTRAHEADER="Authorization: Bearer $(System.AccessToken)"
git -c http.extraheader="$EXTRAHEADER" clone $REPO
cd $(Build.Repository.Name)
MAINBRANCHNAME=$(git rev-parse --abbrev-ref HEAD)
git config http.$REPO.extraHeader "$EXTRAHEADER"
echo -- Merge $(Build.SourceBranchName) to $MAINBRANCHNAME --
git fetch origin $(Build.SourceBranchName) --prune
git merge origin/$(Build.SourceBranchName) -m "merge $(Build.SourceBranchName) to $MAINBRANCHNAME" --no-ff
TAGNAME=$(Release.ReleaseName)
echo -- Create tag named $TAGNAME --
git tag -a -m "$(Build.SourceBranchName) installed to production" $TAGNAME
git push origin $MAINBRANCHNAME
git push origin --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment