Hello!
What happens
I have simple .drone.yml
:
---
kind: pipeline
type: docker
name: Build
platform:
os: windows
arch: amd64
steps:
- name: Restore NuGet
image: mcr.microsoft.com/dotnet/framework/sdk:4.8
commands:
- dotnet restore MyProject.sln
- name: Build
image: mcr.microsoft.com/dotnet/framework/sdk:4.8
commands:
- 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 https://example.com/Examples/example.git
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}:";
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).
WORKAROUND
Set some --depth
to clone step, so $FLAGS
variable becomes nonempty:
clone:
depth: 50