gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
167 stars 42 forks source link

Create_Release_Git_Tag : ERROR: fatal: cannot describe : if no tag at all is defined #384

Closed raandree closed 1 year ago

raandree commented 2 years ago

Problem description

The new task throws if there is no tag yet defined. The call in D:\Git\Sampler\.build\tasks\Create_Release_Git_Tag.build.ps1::115 should be in a try-catch block.

Verbose logs

===============================================================================
            CREATE RELEASE GIT TAG
Creates a git tag for the release that is published to a Gallery
-------------------------------------------------------------------------------
  /publishAzDo/Create_Release_Git_Tag
  C:\BuildWorker1\_work\1\s\output\RequiredModules\Sampler\0.115.0\tasks\Create_Release_Git_Tag.build.ps1:98

    Project Name               = 'DscConfig.Demo'
    Source Path                = 'C:\BuildWorker1\_work\1\s\source'
    Output Directory           = 'C:\BuildWorker1\_work\1\s\output'
    Release Notes path         = 'C:\BuildWorker1\_work\1\s\output\ReleaseNotes.md'
    Built Module Subdirectory  = 'C:\BuildWorker1\_work\1\s\output\Module'
    Module Manifest Path (src) = 'C:\BuildWorker1\_work\1\s\source\DscConfig.Demo.psd1'
    Versioned Output Directory = 'True'
    Built Module Manifest      = 'C:\BuildWorker1\_work\1\s\output\Module\DscConfig.Demo\2.0.0\DscConfig.Demo.psd1'
    Built Module Base          = 'C:\BuildWorker1\_work\1\s\output\Module\DscConfig.Demo\2.0.0'
    Module Version             = '2.0.0-preview0002'
    Module Version Folder      = '2.0.0'
    Pre-release Tag            = 'preview0002'
    Built Module Root Script   = 'C:\BuildWorker1\_work\1\s\output\Module\DscConfig.Demo\2.0.0\DscConfig.Demo.psm1'

ERROR: fatal: cannot describe '6c8eab043fbf66f7137b5bef38a6aef4a7142b37'
At C:\BuildWorker1\_work\1\s\output\RequiredModules\Sampler\0.115.0\tasks\Create_Release_Git_Tag.build.ps1:115 char:21
+     $isCurrentTag = git describe --contains 2> $null
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At C:\BuildWorker1\_work\1\s\output\RequiredModules\Sampler\0.115.0\tasks\Create_Release_Git_Tag.build.ps1:98 char:1
+ task Create_Release_Git_Tag {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build FAILED. 2 tasks, 1 errors, 0 warnings 00:00:07.9374849
git : fatal: cannot describe '6c8eab043fbf66f7137b5bef38a6aef4a7142b37'
At C:\BuildWorker1\_work\1\s\output\RequiredModules\Sampler\0.115.0\tasks\Create_Release_Git_Tag.build.ps1:115 char:21
+     $isCurrentTag = git describe --contains 2> $null
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (fatal: cannot d...a6aef4a7142b37':String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

##[error]PowerShell exited with code '1'.
Finishing: Publish Release

### How to reproduce

Calling the task as part of the publish workflow:

```yaml
  publishAzDo:
    - Publish_Module_To_gallery
    - Publish_GitHub_Wiki_Content
    - Create_Release_Git_Tag
    - Create_Changelog_Branch

Expected behavior

No error to be thrown in a new repo.

Current behavior

See above

Suggested solution

Fix is on the way.

Operating system the target node is running

OsName               : Microsoft Windows 11 Pro for Workstations
OsOperatingSystemSKU : 161
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 22000.1.amd64fre.co_release.210604-1628
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value                                                                                                                   
----                           -----                                                                                                                   
PSVersion                      5.1.22000.653                                                                                                           
PSEdition                      Desktop                                                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                 
BuildVersion                   10.0.22000.653                                                                                                          
CLRVersion                     4.0.30319.42000                                                                                                         
WSManStackVersion              3.0                                                                                                                     
PSRemotingProtocolVersion      2.3                                                                                                                     
SerializationVersion           1.1.0.1

Module version used

Name    Version Path
----    ------- ----
Sampler 0.112.3 C:\Users\randr\OneDrive\Documents\WindowsPowerShell\Modules\Sampler\0.112.3\Sampler.psd1
johlju commented 2 years ago

This does not throw on the Azure DevOps Server that I tested it on. 🤔