Gitlab runner generating ca cert file in invalid directory

Replace this template with your information

Describe your question in as much detail as possible:
Currently, with CI in trace mode, while trying to clone the repository I see the following (redacted) lines in the log.

DEBUG:  438+  >>>> $CurrentDirectory = (Resolve-Path ./).Path
DEBUG:     ! SET $CurrentDirectory = 'C:\'.
<SKIP>
DEBUG:   87+  >>>> New-Item -ItemType directory -Force -Path 
"C:\builds\<ORGANIZATION>\<REPO>.tmp" | out-null
DEBUG:   88+  >>>> 
[System.IO.File]::WriteAllText("$CurrentDirectory\C:\builds\<ORGANIZATION>\<REPO>.
tmp\CI_SERVER_TLS_CA_FILE", <REDACTED>)
<SKIP>
powershell : Exception calling "WriteAllText" with "2" argument(s): "The given 
path's 
At C:\scripts-37118130-6100224507\terminate_with_json_script.ps1:7 char:1
+ powershell -File $Path; $command_exit_code = $LASTEXITCODE
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Exception calli...e given path's  
   :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
$CI_SERVER_TLS_CA_FILE="$CurrentDirectory\C:\builds\<ORGANIZATION>\<REPO>.tmp\CI_S
ERVER_TLS_CA_FILE"
  >>>> $env:CI_SERVER_TLS_CA_FILE=$CI_SERVER_TLS_CA_FILE
<SKIP>
git clone --quiet --filter=tree:0 $Env:CI_REPOSITORY_URL 
$Env:CI_PROJECT_DIR
fatal: unable to access 'https://gitlab.com/<organization>/<repository>.git/': error 
setting certificate verify locations:  CAfile: 

This is on a windows kubernetes runner on gitlab.com.

  • What are you seeing, and how does that differ from what you expect to see?
    I would expect the CA cert to be generated in a valid path (C:\C:\xyz is not a valid absolute path)

  • What version are you on? Are you using self-managed or GitLab.com?

    • GitLab (Hint: /help): gitlab.com
    • Runner (Hint: /admin/runners): windows kubernetes runner
  • Add the CI configuration from .gitlab-ci.yml and other configuration if relevant (e.g. docker-compose.yml)
    The job I’m running is configured as follows:

.git_clone_windows: &git_clone_windows
  - git config --global http.version HTTP/1.1
  - git config --global advice.detachedHead false
  - git config --global user.email "<REDACTED>"
  - git config --global user.name "GitLab CI"
  - |
    if (Test-Path -Path $Env:CI_PROJECT_DIR) {
      Remove-Item -LiteralPath "$Env:CI_PROJECT_DIR" -Force -Recurse
    }
  - git clone --quiet --filter=tree:0 $Env:CI_REPOSITORY_URL $Env:CI_PROJECT_DIR
  - cd $Env:CI_PROJECT_DIR
  - git clean -fxfd
  - git checkout --no-progress $Env:CI_COMMIT_SHA
  - echo "Trying to merge $Env:CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME into $Env:CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME..."
  - |
    if ("$Env:CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA" -ne "") {
      git merge --no-stat $Env:CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA -m "Merge target branch $Env:CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME
    into $Env:CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME"
    }
  - echo "Working on a merge of $Env:CI_COMMIT_SHA of $Env:CI_EXTERNAL_PULL_REQUEST_SOURCE_BRANCH_NAME and $Env:CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_SHA
    of $Env:CI_EXTERNAL_PULL_REQUEST_TARGET_BRANCH_NAME."
  - git lfs pull

.windows_defaults:
  <REDACTED>
  hooks:
    pre_get_sources_script: *git_clone_windows

build-packages-x86-windows:
  stage: build
  extends: .windows_defaults
  image: mcr.microsoft.com/windows/servercore:ltsc2022
  tags:
    - <REDACTED>
  script:
    - <REDACTED>

I’ve managed to run a similar job off of the kubernetes cluster and outside of docker.

  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

I’ve found this link: Writing CI_SERVER_TLS_CA_FILE with custom executor (#21379) · Issues · GitLab.org / gitlab-runner · GitLab, but I don’t know where to find the scripts or how to modify them.

Thanks for taking the time to be thorough in your request, it really helps! :blush: