-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ACTIONS_RUNNER_HOOK_JOB_COMPLETED not able to remove workspace #2154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @rzamponiAtIgt |
Was the root cause of this ever discovered? I have the same issue on setup runner trying to clean out the working directory on windows with powershell. |
I'm having the same issues. |
I was having the same issue, but realized through some testing that the current the script is executed in is the #!/usr/bin/env pwsh
$ErrorActionPreference = "Stop"
Write-Host "PWD: $($PWD)"
$temp = $env:RUNNER_TEMP
$work = (Get-Item -Path $temp).Parent.FullName
Write-Host "Work: $($work)"
Set-Location -Path $work
Write-Host "PWD: $($PWD)"
Remove-Item -Path "$($env:RUNNER_WORKSPACE)" -Recurse -Force
Get-Item -Path "$($env:RUNNER_WORKSPACE)" -ErrorAction Continue This could be remedied with by updating the documentation with this specific use case. This seems like a common task for the completed hook. |
I'm also experiencing this. @chriscarpenter12's suggestion didn't work for me. In my findings, it seems like it's the actual |
I had the same problem on a local windows runner with powershell job completed hooks. The proposed solution does not work for me. I don't know much about powershell atm but as far as I can tell, I think it's related to this issue PowerShell/PowerShell#17149 - the paths in the solution above look like linux paths so maybe it's a difference in windows / linux behavior with Set-Location. For me - the script is being started in one of the directories I want to remove (can check with $PWD) - even changing dirs with The solution that's working for me (which is why I think that it is related to PowerShell/PowerShell#17149 - is to call Here's a script that was playing with to figure out what was happening: $dirToRemove = 'C:\path\to\dir\to\remove'
Write-Output "Originally in: $PWD"
Set-Location -Path 'c:\better\location'
Write-Output "CurrentDirectory:" ([System.IO.Directory]::GetCurrentDirectory())
[System.IO.Directory]::SetCurrentDirectory($PWD)
Write-Output "CurrentDirectory:" ([System.IO.Directory]::GetCurrentDirectory())
Write-Output "My PID: $PID"
if (Test-Path -Path $dirToRemove) {
try {
Remove-Item -Path $dirToRemove -Recurse -Force -ErrorAction Stop
Write-Output "Directory removed successfully with Remove-Item"
} catch {
Write-Output "Remove-Item failed..."
Write-Output $_
# to see what pid has the file / folder still
& "C:\Users\USER\Downloads\Handle\handle.exe" $dirToRemove
}
} else {
Write-Output "Directory doesn't exist."
} |
Describe the bug
Using a simple workflow which just checks out the repository
a simple powershell script
called with ACTIONS_RUNNER_HOOK_JOB_COMPLETED is not able to remove neither GITHUB_WORKSPACE nor RUNNER_WORKSPACE.
Runner Version and Platform
Version of your runner?
2.296.2
OS of the machine running the runner? OSX/Windows/Linux/...
Windows
What's not working?
From documentation I would expect to be able to wipeout the workspace at the end of the run but the Remove-Item command tells me, the directory is locked.
Job Log Output
Runner and Worker's Diagnostic Logs
The text was updated successfully, but these errors were encountered: