Currently we have two repo one for Infra related and one for Source code. when I want to calculate its calculating against Infra branch because that's where its actually running. How can I calculate git version for a source code branch in different repo and apply? I am using Azure pipeline. currently its working for the Infra branch
Calculate tag
- task: gitversion/setup@0
displayName: Install GitVersion
inputs:
versionSpec: '5.x'
- task: gitversion/execute@0
displayName: Determine Version
inputs:
useConfigFile: true
configFilePath: 'global/GitVersion.yml'
Apply Tag
- task: Bash@3
inputs:
targetType: 'inline'
script: |
git config --global user.email "$(Build.RequestedForEmail)"
git config --global user.name "$(Build.RequestedFor)"
if [ $(git tag -l "$(GitVersion.SemVer)") ]; then
echo "Tag $(GitVersion.SemVer) already exists. Skipping Tagging."
else
git tag $(GitVersion.SemVer) -m "release build"
git push origin $(GitVersion.SemVer) --force
fi
Update*
based on this git https://github.com/GitTools/actions/issues/172 I can see we can set target branch, when I set I am getting warning and it picks dev as default.
Multiple source branches have been found, picking the first one (dev). This may result in incorrect commit counting. Options were: dev, release/1.0.1, releases/1.0.2, releases/1.0.0, main
Based on your expectation and update, you may test with the sample below.
azure-pipelines.yml file in the
Infrabranch ofInfrarepo (self/Repo1)This pipeline first checks out the
selfrepo (Infra) into thes/Repo1folder that is relative to the$(Agent.BuildDirectory); then, similarly, it checks out theRepo2(SourceCode) into thes/Repo2folder; see Checkout path;Since the expectation is to tag
Infrabranch from Infra repo, the pipeline then executesgitverionwith thecofigFilein$(Agent.BuildDirectory)/s/Repo1/global/GitVersion.ymland with targetPaht of$(Agent.BuildDirectory)/s/Repo1; this path is where theInfrarepo is checked out.Then with the help of git commands, the pipeline tags
infrawith$(GitVersion.SemVer).