mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-30 10:11:23 +02:00
Another fix for settings field in pipeline config (#579)
close #578 - adjust to new settings field own pipeline config - more test coverage - Fix environment parse of settings - Fix pipeline schema
This commit is contained in:
parent
fe2f269bce
commit
e7cfa902a6
@ -34,25 +34,27 @@ pipeline:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
|
||||
publish-server:
|
||||
group: bundle
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-server
|
||||
dockerfile: docker/Dockerfile.server
|
||||
group: bundle
|
||||
secrets: [docker_username, docker_password]
|
||||
# TODO: only release as next after 0.15.0 got released
|
||||
tag: [next, latest]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-server
|
||||
dockerfile: docker/Dockerfile.server
|
||||
# TODO: only release as next after 0.15.0 got released
|
||||
tag: [next, latest]
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push
|
||||
|
||||
publish-server-alpine:
|
||||
group: bundle
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-server
|
||||
dockerfile: docker/Dockerfile.server.alpine
|
||||
group: bundle
|
||||
secrets: [ docker_username, docker_password ]
|
||||
# TODO: only release as next-alpine after 0.15.0 got released
|
||||
tag: [next-alpine, latest-alpine]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-server
|
||||
dockerfile: docker/Dockerfile.server.alpine
|
||||
# TODO: only release as next-alpine after 0.15.0 got released
|
||||
tag: [next-alpine, latest-alpine]
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push
|
||||
@ -60,11 +62,12 @@ pipeline:
|
||||
publish-agent:
|
||||
group: bundle
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent
|
||||
secrets: [docker_username, docker_password]
|
||||
# TODO: only release as next after 0.15.0 got released
|
||||
tag: [next, latest]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent
|
||||
# TODO: only release as next after 0.15.0 got released
|
||||
tag: [next, latest]
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push
|
||||
@ -72,11 +75,12 @@ pipeline:
|
||||
publish-agent-alpine:
|
||||
group: bundle
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent.alpine
|
||||
secrets: [ docker_username, docker_password ]
|
||||
# TODO: only release as next-alpine after 0.15.0 got released
|
||||
tag: [next-alpine, latest-alpine]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent.alpine
|
||||
# TODO: only release as next-alpine after 0.15.0 got released
|
||||
tag: [next-alpine, latest-alpine]
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push
|
||||
@ -84,10 +88,11 @@ pipeline:
|
||||
publish-cli:
|
||||
group: docker
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli
|
||||
secrets: [docker_username, docker_password]
|
||||
tag: [next]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli
|
||||
tag: next
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push
|
||||
@ -95,10 +100,11 @@ pipeline:
|
||||
publish-cli-alpine:
|
||||
group: docker
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli.alpine
|
||||
secrets: [ docker_username, docker_password ]
|
||||
tag: [next-alpine]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli.alpine
|
||||
tag: next-alpine
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push
|
||||
@ -106,60 +112,66 @@ pipeline:
|
||||
release-server:
|
||||
group: bundle
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-server
|
||||
dockerfile: docker/Dockerfile.server
|
||||
secrets: [docker_username, docker_password]
|
||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-server
|
||||
dockerfile: docker/Dockerfile.server
|
||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||
when:
|
||||
event: tag
|
||||
|
||||
release-server-alpine:
|
||||
group: bundle
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-server
|
||||
dockerfile: docker/Dockerfile.server.alpine
|
||||
secrets: [ docker_username, docker_password ]
|
||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-server
|
||||
dockerfile: docker/Dockerfile.server.alpine
|
||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||
when:
|
||||
event: tag
|
||||
|
||||
release-agent:
|
||||
group: bundle
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent
|
||||
secrets: [docker_username, docker_password]
|
||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent
|
||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||
when:
|
||||
event: tag
|
||||
|
||||
release-agent-alpine:
|
||||
group: bundle
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent.alpine
|
||||
secrets: [ docker_username, docker_password ]
|
||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent.alpine
|
||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||
when:
|
||||
event: tag
|
||||
|
||||
release-cli:
|
||||
group: docker
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli
|
||||
secrets: [docker_username, docker_password]
|
||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli
|
||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||
when:
|
||||
event: tag
|
||||
|
||||
release-cli-alpine:
|
||||
group: docker
|
||||
image: plugins/docker
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli.alpine
|
||||
secrets: [ docker_username, docker_password ]
|
||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli.alpine
|
||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||
when:
|
||||
event: tag
|
||||
|
||||
@ -174,15 +186,16 @@ pipeline:
|
||||
|
||||
release:
|
||||
image: plugins/github-release
|
||||
files:
|
||||
- dist/*.tar.gz
|
||||
- dist/*.deb
|
||||
- dist/*.rpm
|
||||
- dist/checksums.txt
|
||||
title: ${CI_COMMIT_TAG##v}
|
||||
secrets:
|
||||
- source: github_token
|
||||
target: github_release_api_key
|
||||
settings:
|
||||
files:
|
||||
- dist/*.tar.gz
|
||||
- dist/*.deb
|
||||
- dist/*.rpm
|
||||
- dist/checksums.txt
|
||||
title: ${CI_COMMIT_TAG##v}
|
||||
when:
|
||||
event: tag
|
||||
|
||||
|
@ -71,7 +71,10 @@ func sanitizeParamValue(v interface{}) (string, error) {
|
||||
return string(out), nil
|
||||
|
||||
case reflect.Slice, reflect.Array:
|
||||
if !isComplex(t.Elem().Kind()) {
|
||||
if vv.Len() == 0 {
|
||||
return "", nil
|
||||
}
|
||||
if !isComplex(t.Elem().Kind()) || t.Elem().Kind() == reflect.Interface {
|
||||
in := make([]string, vv.Len())
|
||||
for i := 0; i < vv.Len(); i++ {
|
||||
var err error
|
||||
|
@ -18,6 +18,8 @@ func TestParamsToEnv(t *testing.T) {
|
||||
"complex": []struct{ Name string }{{"Jack"}, {"Jill"}},
|
||||
"complex2": struct{ Name string }{"Jack"},
|
||||
"from.address": "noreply@example.com",
|
||||
"tags": stringsToInterface("next", "latest"),
|
||||
"tag": stringsToInterface("next"),
|
||||
}
|
||||
want := map[string]string{
|
||||
"PLUGIN_STRING": "stringz",
|
||||
@ -29,8 +31,18 @@ func TestParamsToEnv(t *testing.T) {
|
||||
"PLUGIN_COMPLEX": `[{"name":"Jack"},{"name":"Jill"}]`,
|
||||
"PLUGIN_COMPLEX2": `{"name":"Jack"}`,
|
||||
"PLUGIN_FROM_ADDRESS": "noreply@example.com",
|
||||
"PLUGIN_TAG": "next",
|
||||
"PLUGIN_TAGS": "next,latest",
|
||||
}
|
||||
got := map[string]string{}
|
||||
assert.NoError(t, paramsToEnv(from, got))
|
||||
assert.EqualValues(t, want, got, "Problem converting plugin parameters to environment variables")
|
||||
}
|
||||
|
||||
func stringsToInterface(val ...string) []interface{} {
|
||||
res := make([]interface{}, len(val))
|
||||
for i := range val {
|
||||
res[i] = val[i]
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
@ -158,6 +158,71 @@ func TestUnmarshalContainers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
from: `publish-agent:
|
||||
group: bundle
|
||||
image: print/env
|
||||
repo: woodpeckerci/woodpecker-agent
|
||||
dockerfile: docker/Dockerfile.agent
|
||||
secrets: [docker_username, docker_password]
|
||||
tag: [next, latest]
|
||||
dry_run: true
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push`,
|
||||
want: []*Container{
|
||||
{
|
||||
Name: "publish-agent",
|
||||
Image: "print/env",
|
||||
Group: "bundle",
|
||||
Secrets: Secrets{Secrets: []*Secret{{
|
||||
Source: "docker_username",
|
||||
Target: "docker_username",
|
||||
}, {
|
||||
Source: "docker_password",
|
||||
Target: "docker_password",
|
||||
}}},
|
||||
Settings: map[string]interface{}{
|
||||
"repo": "woodpeckerci/woodpecker-agent",
|
||||
"dockerfile": "docker/Dockerfile.agent",
|
||||
"tag": stringsToInterface("next", "latest"),
|
||||
"dry_run": true,
|
||||
},
|
||||
Constraints: Constraints{
|
||||
Event: Constraint{Include: []string{"push"}},
|
||||
Branch: Constraint{Include: []string{"${CI_REPO_DEFAULT_BRANCH}"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
from: `publish-cli:
|
||||
group: docker
|
||||
image: print/env
|
||||
settings:
|
||||
repo: woodpeckerci/woodpecker-cli
|
||||
dockerfile: docker/Dockerfile.cli
|
||||
tag: [next]
|
||||
when:
|
||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||
event: push`,
|
||||
want: []*Container{
|
||||
{
|
||||
Name: "publish-cli",
|
||||
Image: "print/env",
|
||||
Group: "docker",
|
||||
Settings: map[string]interface{}{
|
||||
"repo": "woodpeckerci/woodpecker-cli",
|
||||
"dockerfile": "docker/Dockerfile.cli",
|
||||
"tag": stringsToInterface("next"),
|
||||
},
|
||||
Constraints: Constraints{
|
||||
Event: Constraint{Include: []string{"push"}},
|
||||
Branch: Constraint{Include: []string{"${CI_REPO_DEFAULT_BRANCH}"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range testdata {
|
||||
in := []byte(test.from)
|
||||
@ -182,3 +247,11 @@ func TestUnmarshalContainersErr(t *testing.T) {
|
||||
assert.Error(t, err, "wanted error for containers %q", test)
|
||||
}
|
||||
}
|
||||
|
||||
func stringsToInterface(val ...string) []interface{} {
|
||||
res := make([]interface{}, len(val))
|
||||
for i := range val {
|
||||
res[i] = val[i]
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
@ -175,7 +175,7 @@
|
||||
"description": "Change the settings of your plugin. Read more: https://woodpecker-ci.org/docs/usage/plugins/plugins",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": ["boolean", "string", "number"]
|
||||
"type": ["boolean", "string", "number", "array", "object"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user