Skip to content

ACTIONS_RUNNER_HOOK_JOB_COMPLETED not able to remove workspace #2154

@rzamponiAtIgt

Description

@rzamponiAtIgt

Describe the bug

Using a simple workflow which just checks out the repository

name: JCO

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: [self-hosted, windows]
    steps: 
      - uses: actions/checkout@v2

a simple powershell script

$time_to_wait = 30
Write-Output "Wait '${time_to_wait}' seconds for the file system to become unlocked."
Start-Sleep -Seconds $time_to_wait
Remove-Item "${env:GITHUB_WORKSPACE}" -Recurse -WhatIf
Remove-Item "${env:RUNNER_WORKSPACE}" -Recurse -WhatIf

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

A job completed hook has been configured by the self-hosted runner administrator
Run '<path to>\sample_cleanup.ps1'
shell: C:\windows\System32\WindowsPowerShell\v1.0\powershell.EXE -command ". '{0}'"
Wait '30' seconds for the file system to become unlocked.
Remove-Item : Cannot remove the item at 'C:\github_work\<repository name>\<repository name>'
because it is in use.
At <path to>\sample_cleanup.ps1:4 char:1

  • Remove-Item "${env:GITHUB_WORKSPACE}" -Recurse -WhatIf
  •   + CategoryInfo          : InvalidOperation: (:) [Remove-Item], PSInvalidOperationException
      + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RemoveItemCommand
    
    

Remove-Item : Cannot remove the item at 'C:\github_work\<repository name>' because it is in use.
At <path to>\sample_cleanup.ps1:5 char:1

  • Remove-Item "${env:RUNNER_WORKSPACE}" -Recurse -WhatIf
  •   + CategoryInfo          : InvalidOperation: (:) [Remove-Item], PSInvalidOperationException
      + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RemoveItemCommand
    

Runner and Worker's Diagnostic Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions