Revert "Use existing WorkingDir for clone steps (#5023)" (#5047)

This commit is contained in:
Robert Kaussow 2025-04-02 09:21:26 +02:00 committed by GitHub
parent 807fa4289a
commit b4020072b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 27 deletions

View File

@ -56,6 +56,8 @@ MD013:
tables: false tables: false
# Include headings # Include headings
headings: true headings: true
# Include headings
headers: true
# Strict length checking # Strict length checking
strict: false strict: false
# Stern length checking # Stern length checking
@ -71,7 +73,7 @@ MD022:
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content # MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
MD024: MD024:
# Only check sibling headings # Only check sibling headings
siblings_only: true allow_different_nesting: true
# MD025/single-title/single-h1 - Multiple top-level headings in the same document # MD025/single-title/single-h1 - Multiple top-level headings in the same document
MD025: MD025:

View File

@ -646,13 +646,9 @@ For more details and examples check the [Advanced usage docs](./90-advanced-usag
## `clone` ## `clone`
Woodpecker automatically configures a default clone step if it is not explicitly defined. If you are using the `local` backend, the [plugin-git](https://github.com/woodpecker-ci/plugin-git) binary must be in your `$PATH` for the default clone step to work. If this is not the case, you can still write a manual clone step. Woodpecker automatically configures a default clone step if not explicitly defined. When using the `local` backend, the [plugin-git](https://github.com/woodpecker-ci/plugin-git) binary must be on your `$PATH` for the default clone step to work. If not, you can still write a manual clone step.
:::info You can manually configure the clone step in your workflow for customization:
Clone step containers use `/woodpecker` as the working directory. It is recommended that clone plugins do not rely on the working directory and use absolute paths instead.
:::
You can manually configure the clone step in your workflow to customize it:
```diff ```diff
+clone: +clone:
@ -667,7 +663,7 @@ You can manually configure the clone step in your workflow to customize it:
- go test - go test
``` ```
Example configuration to override the depth: Example configuration to override depth:
```diff ```diff
clone: clone:
@ -688,7 +684,7 @@ Example configuration to use a custom clone plugin:
### Git Submodules ### Git Submodules
To use the credentials used to clone the repository to clone its submodules, update `.gitmodules` to use `https` instead of `git`: To use the credentials that cloned the repository to clone it's submodules, update `.gitmodules` to use `https` instead of `git`:
```diff ```diff
[submodule "my-module"] [submodule "my-module"]
@ -714,10 +710,6 @@ steps:
## `skip_clone` ## `skip_clone`
:::warning
The default clone step is executed as `root` to ensure that the workspace directory can be accessed by any user (`0777`). This is necessary to allow rootless step containers to write to the workspace directory. If a rootless step container is used with `skip_clone`, the user must ensure a suitable workspace directory that can be accessed by the unprivileged container use, e.g. `/tmp`.
:::
By default Woodpecker is automatically adding a clone step. This clone step can be configured by the [clone](#clone) property. If you do not need a `clone` step at all you can skip it using: By default Woodpecker is automatically adding a clone step. This clone step can be configured by the [clone](#clone) property. If you do not need a `clone` step at all you can skip it using:
```yaml ```yaml

View File

@ -4,14 +4,6 @@ To enhance the usability of Woodpecker and meet evolving security standards, occ
## `next` ## `next`
### User-facing migrations
#### Clone plugin working directory
- Clone plugins now use `/woodpecker` as working directory instead of `/woodpecker/<workspacePath>/<directory>`. If you use the default clone plugin, you do not need to make any changes. If you use a custom clone plugin, please ensure the plugin uses absolute paths and don't rely on the working directory.
#### Miscellaneous
- (Kubernetes) Deprecated `step` label on pod in favor of new namespaced label `woodpecker-ci.org/step`. The `step` label will be removed in a future update. - (Kubernetes) Deprecated `step` label on pod in favor of new namespaced label `woodpecker-ci.org/step`. The `step` label will be removed in a future update.
## 3.0.0 ## 3.0.0

View File

@ -96,7 +96,7 @@ func TestCompilerCompile(t *testing.T) {
OnSuccess: true, OnSuccess: true,
Failure: "fail", Failure: "fail",
Volumes: []string{defaultVolume.Name + ":/woodpecker"}, Volumes: []string{defaultVolume.Name + ":/woodpecker"},
WorkingDir: "/woodpecker", WorkingDir: "/woodpecker/src/github.com/octocat/hello-world",
WorkspaceBase: "/woodpecker", WorkspaceBase: "/woodpecker",
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"clone"}}}, Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"clone"}}},
ExtraHosts: []backend_types.HostAlias{}, ExtraHosts: []backend_types.HostAlias{},

View File

@ -96,7 +96,7 @@ func (c *Compiler) createProcess(container *yaml_types.Container, workflow *yaml
detached = true detached = true
} }
workingDir = c.stepWorkingDir(container, stepType) workingDir = c.stepWorkingDir(container)
getSecretValue := func(name string) (string, error) { getSecretValue := func(name string) (string, error) {
name = strings.ToLower(name) name = strings.ToLower(name)
@ -185,7 +185,7 @@ func (c *Compiler) createProcess(container *yaml_types.Container, workflow *yaml
}, nil }, nil
} }
func (c *Compiler) stepWorkingDir(container *yaml_types.Container, stepType backend_types.StepType) string { func (c *Compiler) stepWorkingDir(container *yaml_types.Container) string {
if path.IsAbs(container.Directory) { if path.IsAbs(container.Directory) {
return container.Directory return container.Directory
} }
@ -193,9 +193,6 @@ func (c *Compiler) stepWorkingDir(container *yaml_types.Container, stepType back
if container.IsPlugin() { if container.IsPlugin() {
base = pluginWorkspaceBase base = pluginWorkspaceBase
} }
if stepType == backend_types.StepTypeClone {
return base
}
return path.Join(base, c.workspacePath, container.Directory) return path.Join(base, c.workspacePath, container.Directory)
} }