Docker runner on Windows fails to clone


What happens

I have simple .drone.yml:

kind: pipeline
type: docker
name: Build

  os: windows
  arch: amd64

- name: Restore NuGet
      - dotnet restore MyProject.sln

- name: Build
      - dotnet publish -c Release -o out

but it fails on first step, workspace is empty. In builtin clone step I have these error messages:

git init
Initialized empty Git repository in C:/drone/src/.git/
git remote add origin
git fetch  origin +refs/heads/feature/example:
fatal: no path specified; see 'git help pull' for valid url syntax
git checkout XXX -f feature/example
fatal: reference is not a tree: XXX

PS: Some variable names are changed.

Why it happens

I tried to reproduce error step-by-step in container by hand. It fails on command:

git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";

Source of clone script

I figured out that if $FLAGS variable is empty and exists in command - then it fails. But if I remove this variable from command or set something in it(becomes nonempty), then it works fine.
Seems like powershell parses command with extra spaces like command where some arguments are empty strings, so git fails on invalid URL(it’s an empty string).


Set some --depth to clone step, so $FLAGS variable becomes nonempty:

  depth: 50