GitVersion
GitVersion copied to clipboard
[Bug] Unable to handle pipeline with multiple repo resources in Azure DevOps
Describe the bug When multiple repos are checked out in Azure DevOps build pipeline, the GitVersion task was not able to run under one of the specified repo.
Build Script
name: $(BuildId)_$(date:yyyyMMdd)
trigger: none
resources:
repositories:
- repository: dataRepo
type: git
name: my-data-repo
pool:
vmImage: 'ubuntu-18.04'
workspace:
clean: all
steps:
- checkout: self
path: source # Source code is saved in /home/vsts/work/1/s/source folder
- checkout: dataRepo
path: dataRepo # Additional data is save in /home/vsts/work/1/s/dataRepo folder
- task: UseDotNet@2
displayName: Prepare Dotnet for GitVersion
inputs:
packageType: 'sdk'
version: '2.1.x'
- task: GitVersion@5
displayName: GitVersion
inputs:
runtime: 'core'
configFilePath: '$(Build.SourcesDirectory)/source/GitVersion.yml'
Expected Behavior
GitVersion can generate version info based on triggering repo "self"
Actual Behavior
I cannot find a way asking GitVersion to parsing the information from $(Build.SourcesDirectory)/source Apparently the git version task was run under $(Build.SourcesDirectory) folder:
2020-08-25T06:14:51.3565823Z ##[section]Starting: GitVersion
2020-08-25T06:14:51.3576703Z ==============================================================================
2020-08-25T06:14:51.3577506Z Task : GitVersion Task
2020-08-25T06:14:51.3577836Z Description : Easy Semantic Versioning (http://semver.org) for projects using Git
2020-08-25T06:14:51.3578130Z Version : 5.0.1
2020-08-25T06:14:51.3578371Z Author : GitVersion Contributors
2020-08-25T06:14:51.3578899Z Help : See the [documentation](http://gitversion.readthedocs.org/en/latest/) for help
2020-08-25T06:14:51.3579308Z ==============================================================================
2020-08-25T06:14:56.0035993Z [command]/opt/hostedtoolcache/dotnet/dotnet /home/vsts/work/_tasks/GitVersion_e5983830-3f75-11e5-82ed-81492570a08e/5.0.1/core/GitVersion.dll /home/vsts/work/1/s /output buildserver /nofetch /config /home/vsts/work/1/s/source/GitVersion.yml
2020-08-25T06:14:56.1437117Z INFO [08/25/20 6:14:56:13] Working directory: /home/vsts/work/1/s
2020-08-25T06:14:56.1446187Z INFO [08/25/20 6:14:56:14] IsDynamicGitRepository: False
2020-08-25T06:14:56.1809420Z ERROR [08/25/20 6:14:56:18] An unexpected error occurred:
2020-08-25T06:14:56.1812406Z System.IO.DirectoryNotFoundException: Can't find the .git directory in /home/vsts/work/1/s
2020-08-25T06:14:56.1813011Z at GitVersion.GitPreparer.GetDotGitDirectory() in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 144
2020-08-25T06:14:56.1813521Z at GitVersion.GitPreparer.GetProjectRootDirectory() in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 162
2020-08-25T06:14:56.1814162Z at GitVersion.ConfigFileLocator.Verify(GitPreparer gitPreparer, IFileSystem fileSystem) in D:\a\1\s\src\GitVersionCore\Configuration\ConfigFileLocator.cs:line 57
2020-08-25T06:14:56.1814761Z at GitVersion.Program.VerifyArgumentsAndRun() in D:\a\1\s\src\GitVersionExe\Program.cs:line 95
2020-08-25T06:14:56.1815117Z INFO [08/25/20 6:14:56:18]
2020-08-25T06:14:56.1815449Z INFO [08/25/20 6:14:56:18] Attempting to show the current git graph (please include in issue):
2020-08-25T06:14:56.1815831Z INFO [08/25/20 6:14:56:18] Showing max of 100 commits
2020-08-25T06:14:56.1848158Z INFO [08/25/20 6:14:56:13] Working directory: /home/vsts/work/1/s
2020-08-25T06:14:56.1851999Z INFO [08/25/20 6:14:56:14] IsDynamicGitRepository: False
2020-08-25T06:14:56.1852320Z ERROR [08/25/20 6:14:56:18] An unexpected error occurred:
2020-08-25T06:14:56.1855178Z System.IO.DirectoryNotFoundException: Can't find the .git directory in /home/vsts/work/1/s
2020-08-25T06:14:56.1855703Z at GitVersion.GitPreparer.GetDotGitDirectory() in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 144
2020-08-25T06:14:56.1856260Z at GitVersion.GitPreparer.GetProjectRootDirectory() in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 162
2020-08-25T06:14:56.1856905Z at GitVersion.ConfigFileLocator.Verify(GitPreparer gitPreparer, IFileSystem fileSystem) in D:\a\1\s\src\GitVersionCore\Configuration\ConfigFileLocator.cs:line 57
2020-08-25T06:14:56.1857916Z at GitVersion.Program.VerifyArgumentsAndRun() in D:\a\1\s\src\GitVersionExe\Program.cs:line 95
2020-08-25T06:14:56.1858309Z INFO [08/25/20 6:14:56:18]
2020-08-25T06:14:56.1858640Z INFO [08/25/20 6:14:56:18] Attempting to show the current git graph (please include in issue):
2020-08-25T06:14:56.1859138Z INFO [08/25/20 6:14:56:18] Showing max of 100 commits
2020-08-25T06:14:56.2030882Z ##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 1
2020-08-25T06:14:56.2047241Z ##[section]Finishing: GitVersion
- Version Used:
- Hosted Agent 'ubuntu-18.04'
Found a workaround, I have to change the checkout path for my source code to "s", to match the default gitversion work directory:
- checkout: self
paht: s
- checkout: dataRepo
path: dataRepo # Additional data is save in /home/vsts/work/1/s/dataRepo folder
Running into the same issue
Same issue here!
I have the same problem and used the workaround that the tasks of GitVersion are implemented in the separate stage. In the stage, only the resource repository is checked out. The required git information is transferred into the second stage by variables. Just similar with the Example 10: https://github.com/GitTools/actions/blob/main/docs/examples/azure/gitversion/execute/usage-examples.md
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.
GitVersion@5 is unsupported, please use https://marketplace.visualstudio.com/items?itemName=gittools.gittools isntead, Closing
Running into the same issue