Skip to content

Commit

Permalink
Revert "Fail hard on deprecated pipeline keys (woodpecker-ci#2180)"
Browse files Browse the repository at this point in the history
This reverts commit 71666f0.
  • Loading branch information
qwerty287 committed Oct 31, 2023
1 parent 5d1acc3 commit 7793a7b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 0 additions & 2 deletions docs/docs/91-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Some versions need some changes to the server configuration or the pipeline conf
## next (2.0.0)

- Dropped deprecated `CI_BUILD_*`, `CI_PREV_BUILD_*`, `CI_JOB_*`, `*_LINK`, `CI_SYSTEM_ARCH`, `CI_REPO_REMOTE` built-in environment variables
- Dropped deprecated `pipeline:` keyword in favor of `steps:` in pipeline config
- Dropped deprecated `branches:` filter in favor of global [`when.branch`](./20-usage/20-workflow-syntax.md#branch-1) filter
- Deprecated `platform:` filter in favor of `labels:`, [read more](./20-usage/20-workflow-syntax.md#filter-by-platform)
- Secrets `event` property was renamed to `events` and `image` to `images` as both are lists. The new property `events` / `images` has to be used in the api and as cli argument. The old properties `event` and `image` were removed.
- The secrets `plugin_only` option was removed. Secrets with images are now always only available for plugins using listed by the `images` property. Existing secrets with a list of `images` will now only be available to the listed images if they are used as a plugin.
Expand Down
19 changes: 14 additions & 5 deletions pipeline/frontend/yaml/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"codeberg.org/6543/xyaml"

"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/constraint"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
)
Expand All @@ -31,14 +32,21 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
return nil, err
}

// fail hard on deprecated branch filter
// support deprecated branch filter
if out.BranchesDontUseIt != nil {
return nil, fmt.Errorf("\"branches:\" filter got removed, use \"branch\" in global when filter instead")
if out.When.Constraints == nil {
out.When.Constraints = []constraint.Constraint{{Branch: *out.BranchesDontUseIt}}
} else if len(out.When.Constraints) == 1 && out.When.Constraints[0].Branch.IsEmpty() {
out.When.Constraints[0].Branch = *out.BranchesDontUseIt
} else {
return nil, fmt.Errorf("could not apply deprecated branches filter into global when filter")
}
out.BranchesDontUseIt = nil
}

// fail hard on deprecated pipeline keyword
if len(out.PipelineDontUseIt.ContainerList) != 0 {
return nil, fmt.Errorf("\"pipeline:\" got removed, use \"steps:\" instead")
// support deprecated pipeline keyword
if len(out.PipelineDontUseIt.ContainerList) != 0 && len(out.Steps.ContainerList) == 0 {
out.Steps.ContainerList = out.PipelineDontUseIt.ContainerList
}

// support deprecated platform filter
Expand All @@ -51,6 +59,7 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
}
out.PlatformDontUseIt = ""
}
out.PipelineDontUseIt.ContainerList = nil

return out, nil
}
Expand Down
7 changes: 6 additions & 1 deletion pipeline/frontend/yaml/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestParseLegacy(t *testing.T) {
sampleYamlPipelineLegacy := `
platform: linux/amd64
steps:
pipeline:
say hello:
image: bash
commands: echo hello
Expand All @@ -157,6 +157,11 @@ steps:
say hello:
image: bash
commands: echo hello
pipeline:
old crap:
image: bash
commands: meh!
`

workflow1, err := ParseString(sampleYamlPipelineLegacy)
Expand Down
5 changes: 2 additions & 3 deletions pipeline/stepBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ steps:
}
}

func TestRootWhenBranchFilter(t *testing.T) {
func TestBranchFilter(t *testing.T) {
t.Parallel()

b := StepBuilder{
Expand All @@ -307,8 +307,7 @@ func TestRootWhenBranchFilter(t *testing.T) {
steps:
xxx:
image: scratch
when:
branch: main
branches: main
`)},
{Data: []byte(`
steps:
Expand Down

0 comments on commit 7793a7b

Please sign in to comment.