Move cleanup to seperate build step
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
b3e33a7027
commit
485a318bcb
15
.drone.yml
15
.drone.yml
@ -57,6 +57,21 @@ steps:
|
|||||||
path: /output
|
path: /output
|
||||||
- name: scratch
|
- name: scratch
|
||||||
path: /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
|
- name: Trigger downstream builds
|
||||||
image: plugins/downstream
|
image: plugins/downstream
|
||||||
settings:
|
settings:
|
||||||
|
@ -227,18 +227,5 @@
|
|||||||
" /output/Windows-Server-2019-LTSC.ova"
|
" /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}}'"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]]
|
]]
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ Param(
|
|||||||
[string]$VSphereUsername,
|
[string]$VSphereUsername,
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[string]$VSpherePassword,
|
[string]$VSpherePassword,
|
||||||
[Parameter(Mandatory)]
|
|
||||||
[string]$BuildName
|
|
||||||
)
|
)
|
||||||
|
|
||||||
$PowerCliConfigurationSplat = @{
|
$PowerCliConfigurationSplat = @{
|
||||||
@ -29,7 +27,7 @@ $ConnectVIServerSplat = @{
|
|||||||
Connect-VIServer @ConnectVIServerSplat | Out-Null
|
Connect-VIServer @ConnectVIServerSplat | Out-Null
|
||||||
|
|
||||||
$GetVMSplat = @{
|
$GetVMSplat = @{
|
||||||
Name = "$($VMName)*"
|
Name = "*$($VMName)*"
|
||||||
ErrorAction = 'SilentlyContinue'
|
ErrorAction = 'SilentlyContinue'
|
||||||
}
|
}
|
||||||
If ([boolean](Get-VM @GetVMSplat)) {
|
If ([boolean](Get-VM @GetVMSplat)) {
|
||||||
@ -45,7 +43,7 @@ If ([boolean](Get-VM @GetVMSplat)) {
|
|||||||
Disconnect-VIServer * -Confirm:$False
|
Disconnect-VIServer * -Confirm:$False
|
||||||
|
|
||||||
$RemoveItemSplat = @{
|
$RemoveItemSplat = @{
|
||||||
Path = "/scratch/$($BuildName)/*"
|
Path = "/scratch/*"
|
||||||
Recurse = $True
|
Recurse = $True
|
||||||
Force = $True
|
Force = $True
|
||||||
Confirm = $False
|
Confirm = $False
|
||||||
|
Loading…
Reference in New Issue
Block a user