Hello everyone,
I'm running a pipeline on a Self hosted Windows runner in Bitbucket Pipelines and need to clean the temporary files located in atlassian_runners\atlassian-bitbucket-pipelines-runner\temp\* as not doing that while running docker containers in windows using the runner will move the runner into unhealthy state. (I have built my own wrapper around the self hosted windows runner as Windows Docker Runners aren't supported in Bitbucket Pipelines yet). See my other question for more hints on how I am doing it. https://community.atlassian.com/t5/Bitbucket-questions/Issues-running-Windows-Docker-Container-on-Pipelines-Self-hosted/qaq-p/2735498 However, I'm struggling to dynamically obtain the user profile path. My goal is to avoid hardcoding the user profile path and handle it dynamically within the script.
Here's what I've tried so far:
Using [System.Environment]::GetFolderPath('UserProfile')
:
This returns the system profile path (C:\Windows\system32\config\systemprofile
) instead of the intended user profile path. It seems that the script runs under a different context (Possibly in a Sandboxed JVM environment) in the Bitbucket pipeline.
Questions:
Any help or guidance would be greatly appreciated!
Regards,
Gajesh
Hi Gajesh,
The environment variable $env:USERPROFILE should give you the path to the current user's home directory during a Pipelines build with self-hosted Windows runners.
If the runner goes into an unhealthy state consistently, I suggest addressing that issue first. Possible causes for the runner being unable to clean the build directory are
I suggest looking into these two possible causes first to prevent the runner from going into an unhealthy state.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.