GitTools / actions

GitHub Action that installs and uses the GitVersion and GitReleaseManager tools
MIT License
218 stars 63 forks source link

[ISSUE]: Task fails with simply "command failed" when configuration errors exist #1229

Open mtaylorfsmb opened 4 weeks ago

mtaylorfsmb commented 4 weeks ago

Prerequisites

GitVersion package

AzureDevops task

What are you seeing?

We upgraded from task v0/GitVersion v5 to task v3/GitVersion v6. We made no changes to your gitversion config file that is used by all our builds. We didn't realize that the config format had changed. When the execute task ran all we got in the output was a "command failed" message. There was no indication why it failed or what was wrong.

The only way we diagnosed this issue was by cloning the repo locally, dropping in the config file that is used and then running the same command line that the build server runs. This revealed that our config file had entries that are no longer supported.

What is expected?

If an error occurs while attempting to run gitversion then the detailed error information should be passed back up to the output log so the problem can be diagnosed without having to manually replicate the build environment.

It was also frustrating to have to manually figure out what breaking changes were made to both the task and underlying Gitversion config. To fix the config we had to fix the one error that was reported, rerun the process, fix the next error. If a migration document or similar was available (maybe it is?) then this would have sped up the process.

Steps to Reproduce

Use the latest task/gitversion tooling in a DevOps build with a config file that contains invalid data. Example of invalid data would be a config that was valid in older versions. Here's an example.

# Configuration file for GitVersion
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: None
commit-message-incrementing: Enabled  # MergeMessageOnly doesn't seem to work properly
mode: ContinuousDelivery  
increment: Patch
branches:
  # main uses a version based upon release tag plus any commits to branch with commit messages for PRs
  main:
    regex: ^(master|main)
    tag: ''    
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    is-mainline: true        

  # release uses the version in the branch name (+hotfix) and increments patch if there has been any changes since then
  release:
    regex: release?[/-]
    tag: 'hotfix'
    source-branches:
    - master
    - main
    increment: Patch
    is-release-branch: true         

Output log or link to your CI build (if appropriate).

2024-08-16T19:29:21.4591471Z ##[debug]getVariable - INPUT_TARGETPATH: D:\a\1\s\src
2024-08-16T19:29:21.4591841Z ##[debug]getVariable - INPUT_DISABLECACHE: false
2024-08-16T19:29:21.4592214Z ##[debug]getVariable - INPUT_DISABLENORMALIZATION: false
2024-08-16T19:29:21.4592600Z ##[debug]getVariable - INPUT_DISABLESHALLOWCLONECHECK: false
2024-08-16T19:29:21.4592984Z ##[debug]getVariable - INPUT_USECONFIGFILE: true
2024-08-16T19:29:21.4593366Z ##[debug]getVariable - INPUT_CONFIGFILEPATH: D:\a\1\s\src\gitversion.yml
2024-08-16T19:29:21.4593745Z ##[debug]getVariable - INPUT_OVERRIDECONFIG: 
2024-08-16T19:29:21.4594109Z ##[debug]getVariable - INPUT_UPDATEASSEMBLYINFO: false
2024-08-16T19:29:21.4594485Z ##[debug]getVariable - INPUT_UPDATEASSEMBLYINFOFILENAME: 
2024-08-16T19:29:21.4594859Z ##[debug]getVariable - BUILD_SOURCESDIRECTORY: D:\a\1\s
2024-08-16T19:29:21.4595368Z Command: git -C D:/a/1/s/src rev-parse --is-shallow-repository
2024-08-16T19:29:21.4595731Z ##[debug]getVariable - INPUT_CONFIGFILEPATH: D:\a\1\s\src\gitversion.yml
2024-08-16T19:29:21.4596120Z ##[debug]getVariable - BUILD_SOURCESDIRECTORY: D:\a\1\s
2024-08-16T19:29:21.4596528Z ##[debug]getVariable - GITVERSION_PATH: C:\hostedtoolcache\windows\GitVersion.Tool\6.0.2
2024-08-16T19:29:21.4597120Z Command: C:\hostedtoolcache\windows\GitVersion.Tool\6.0.2\dotnet-gitversion.exe D:/a/1/s/src /output json /output buildserver /config D:\a\1\s\src\gitversion.yml
2024-08-16T19:29:21.6649481Z ##[debug]GitVersion failed
2024-08-16T19:29:21.6650370Z ##[debug]task result: Failed
2024-08-16T19:29:21.6701577Z ##[error]Command failed: C:\hostedtoolcache\windows\GitVersion.Tool\6.0.2\dotnet-gitversion.exe D:/a/1/s/src /output json /output buildserver /config D:\a\1\s\src\gitversion.yml

2024-08-16T19:29:21.6711499Z ##[debug]Processed: ##vso[task.issue type=error;]Command failed: C:\hostedtoolcache\windows\GitVersion.Tool\6.0.2\dotnet-gitversion.exe D:/a/1/s/src /output json /output buildserver /config D:\a\1\s\src\gitversion.yml

2024-08-16T19:29:21.6713813Z ##[debug]Processed: ##vso[task.complete result=Failed;done=true;]Command failed: C:\hostedtoolcache\windows\GitVersion.Tool\6.0.2\dotnet-gitversion.exe D:/a/1/s/src /output json /output buildserver /config D:\a\1\s\src\gitversion.yml