Move cleanup to seperate build step
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Danny Bessems 2021-02-14 13:22:34 +01:00
parent b3e33a7027
commit 485a318bcb
3 changed files with 17 additions and 17 deletions

View File

@ -57,6 +57,21 @@ steps:
path: /output
- name: scratch
path: /scratch
- name: Remove temporary resources
image: bv11-cr01.bessems.eu/library/packer-extended
commands:
- |
pwsh -file scripts/Remove-Resources.ps1 \
-VMName '$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10}' \
-VSphereFQDN 'bv11-vc01.bessems.lan' \
-VSphereUsername 'administrator@vsphere.local' \
-VSpherePassword '$${VSPHERE_PASSWORD}'
environment:
VSPHERE_PASSWORD:
from_secret: vsphere_password
volumes:
- name: scratch
path: /scratch
- name: Trigger downstream builds
image: plugins/downstream
settings:

View File

@ -227,18 +227,5 @@
" /output/Windows-Server-2019-LTSC.ova"
]
}
],
[
{
"type": "shell-local",
"inline": [
"pwsh -file scripts/Remove-Resources.ps1 \\",
" -VMName '{{user `vm_guestos`}}-{{user `vm_name`}}' \\",
" -VSphereFQDN '{{user `vcenter_server`}}' \\",
" -VSphereUsername '{{user `vsphere_username`}}' \\",
" -VSpherePassword '{{user `vsphere_password`}}' \\",
" -BuildName '{{build_name}}'"
]
}
]]
}

View File

@ -8,8 +8,6 @@ Param(
[string]$VSphereUsername,
[Parameter(Mandatory)]
[string]$VSpherePassword,
[Parameter(Mandatory)]
[string]$BuildName
)
$PowerCliConfigurationSplat = @{
@ -29,7 +27,7 @@ $ConnectVIServerSplat = @{
Connect-VIServer @ConnectVIServerSplat | Out-Null
$GetVMSplat = @{
Name = "$($VMName)*"
Name = "*$($VMName)*"
ErrorAction = 'SilentlyContinue'
}
If ([boolean](Get-VM @GetVMSplat)) {
@ -45,7 +43,7 @@ If ([boolean](Get-VM @GetVMSplat)) {
Disconnect-VIServer * -Confirm:$False
$RemoveItemSplat = @{
Path = "/scratch/$($BuildName)/*"
Path = "/scratch/*"
Recurse = $True
Force = $True
Confirm = $False