#7066·woodpecker

More robust command execution on Windows

Author: hasufellCreated Aug 24, 2026Updated Sep 8, 2026
Labelsrefactorbackend/localos/windows

There's currently several issues with command execution:

  1. on windows we use iex, which in some cases may require careful escaping to work correctly
  2. the script is saved in an environment variable CI_SCRIPT and may exceed length limits (32K on windows I think and 2mb on linux, for both args and env vars... I haven't tested in detail yet)
  3. the + cmd print command works poorly with odd strings (especially on windows)

A prior attempt at fixing 1 was at https://github.com/woodpecker-ci/woodpecker/pull/6969 but it actually made point 2 worse.

1 can be fixed by feeding the actual script via stdin to the shell. This is already implemented for libvirt and ssh in my libvirt wip patch: https://github.com/woodpecker-ci/woodpecker/pull/6985 I don't feel comfortable at the moment to implement this for docker and kubernetes, since I'm not very familiar with those backends yet and it would sidetrack my libvirt work.

If we feed the script via stdin, we also don't really need the env variable anymore, I guess. That would be a breaking change potentially though and open the question on how to debug the script as a whole.

I have had success with fixing 3 via heredoc, e.g.:

  • windows:
    go
    const traceScriptWin = `
    Write-Output @'
    + %s
    '@
    
    & {
      %s ;
      if ($LASTEXITCODE) { exit $LASTEXITCODE } ;
    } ;
    `
  • posix:
    go
    const traceScript = `
    cat <<'WOODPECKER_EOF'
    + %s
    WOODPECKER_EOF
    {
        %s
    }
    `

Source: woodpecker-ci/woodpecker