This repository has been archived on 2023-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
DroneHelper/src/State/Write-FailureStateFile.ps1
OCram85 8fd180b776
Some checks reported errors
continuous-integration/drone/tag Build was killed
initial migration
2022-07-13 13:59:25 +02:00

49 lines
1.2 KiB
PowerShell

function Write-FailureStateFile() {
<#
.SYNOPSIS
Writes the current pipeline step into failure log.
.DESCRIPTION
This Cmdlet is used to mark single steps as failed without stopping the complete pipeline.
.PARAMETER StepName
The current DroneHelper step name which should be added into to the log.
.INPUTS
[None] No pipeline input.
.OUTPUTS
[None] No pipeline output.
.EXAMPLE
Write-FailureStateFile
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSUseConsistentWhitespace',
'',
Justification = 'justification'
)]
param (
[Parameter(Mandatory = $true)]
[string]$StepName
)
process {
$Repo = Get-RepoPath
$WriteParams = @{
FilePath = $Repo.FailureLogPath
Encoding = 'utf8'
NoClobber = $true
Force = $true
InputObject = $StepName
}
if ( Test-Path -Path $Repo.FailureLogPath ) {
$WriteParams.Append = $true
}
Out-File @WriteParams
}
}