OCram85/DroneHelper
OCram85
/
DroneHelper
Archived
1
0
Fork 0
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

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
}
}