Skip to main content
Version: 3.21.x

Local

danger

The local backend executes pipelines on the local system without any isolation.

note

Currently we do not support services for this backend. Read more here.

Since the commands run directly in the same context as the agent (same user, same filesystem), a malicious pipeline could be used to access the agent configuration especially the WOODPECKER_AGENT_SECRET variable. Steps do not inherit this variable from the agent, but they can still read the secret in other ways.

It is recommended to use this backend only for private setup where the code and pipeline can be trusted. It should not be used in a public instance where anyone can submit code or add new repositories. The agent should not run as a privileged user (root).

Also see security boundaries.

The local backend will use a random directory in $TMPDIR to store the cloned code and execute commands.

In order to use this backend, you need to download (or build) the agent, configure it and run it on the host machine.

The local backend is supported on Windows, macOS, FreeBSD and OpenBSD; see Supported platforms for the full component and backend matrix.

Step specific configuration​

Shell​

The image entrypoint is used to specify the shell, such as bash or fish, that is used to run the commands.

.woodpecker.yaml
steps:
- name: build
image: bash
commands: [...]

By default, the shell executable is resolved using its name from PATH. The executable path can be overridden with an environment variable named WOODPECKER_SHELL_PATH_<shell>.

For example, to use Bash from a custom location:

WOODPECKER_SHELL_PATH_bash=/custom/path/bash

C# scripts can be executed using csi, dotnet-script, or csharp:

.woodpecker.yaml
steps:
- name: build
image: csi
commands:
- '#r "System.Xml"'
- 'using System;'
- 'Console.WriteLine("Hello from C#");'
- |
Console.WriteLine("Second command");
Console.WriteLine("Third command");

The commands are combined into a temporary .csx file which is passed to the script runner. csi is provided by Visual Studio, dotnet-script is cross-platform, and csharp is provided by Mono.

Command output​

Like other supported shells, C# script runners emit command markers to associate script output with individual entries in commands.

However, C# script directives and declarations may need to appear before executable statements. To accommodate this, command markers for initial header entries are deferred until the first executable entry.

An entry is considered part of the header if it starts with a preprocessor or script directive (#), a comment (// or /*), or a using directive. Leading whitespace is ignored. Empty or whitespace-only entries are also considered part of the header.

When the first executable entry is encountered, all deferred command markers are emitted before executing that entry. From that point onward, each entry is preceded by its command marker, just as with other shells.

If the script contains only header entries, their command markers are emitted at the end of the script.

Each YAML list item is handled as a single entry, including multiline blocks. Workflow authors should therefore keep script directives, imports, and other declarations in separate header entries, without executable statements that produce output. Once normal command logging has started, subsequent entries are no longer treated as header entries.

As with other shells, a custom executable location can be configured using WOODPECKER_SHELL_PATH_<shell>.

Plugins​

steps:
- name: build
image: /usr/bin/tree

If no commands are provided, plugins are treated in the usual manner. In the context of the local backend, plugins are simply executable binaries, which can be located using their name if they are listed in $PATH, or through an absolute path.

Environment variables​

BACKEND_LOCAL_TEMP_DIR​

  • Name: WOODPECKER_BACKEND_LOCAL_TEMP_DIR
  • Default: default temp directory

Directory to create folders for workflows.


BACKEND_LOCAL_ISOLATED_HOME​

  • Name: WOODPECKER_BACKEND_LOCAL_ISOLATED_HOME
  • Default: true

Sets HOME, USERPROFILE and related variables to an isolated directory for each workflow. If set to false, the user's own home directory is used and no netrc file is written.


BACKEND_LOCAL_PLUGIN_GIT_VERSION​

  • Name: WOODPECKER_BACKEND_LOCAL_PLUGIN_GIT_VERSION
  • Default: latest

The plugin-git release to download for the clone step if plugin-git is not in $PATH, for example 2.12.1.