mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-05 10:20:36 +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,11 +34,12 @@ pipeline:
|
|||||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
publish-server:
|
publish-server:
|
||||||
group: bundle
|
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
group: bundle
|
||||||
|
secrets: [docker_username, docker_password]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-server
|
repo: woodpeckerci/woodpecker-server
|
||||||
dockerfile: docker/Dockerfile.server
|
dockerfile: docker/Dockerfile.server
|
||||||
secrets: [docker_username, docker_password]
|
|
||||||
# TODO: only release as next after 0.15.0 got released
|
# TODO: only release as next after 0.15.0 got released
|
||||||
tag: [next, latest]
|
tag: [next, latest]
|
||||||
when:
|
when:
|
||||||
@ -46,11 +47,12 @@ pipeline:
|
|||||||
event: push
|
event: push
|
||||||
|
|
||||||
publish-server-alpine:
|
publish-server-alpine:
|
||||||
group: bundle
|
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
group: bundle
|
||||||
|
secrets: [ docker_username, docker_password ]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-server
|
repo: woodpeckerci/woodpecker-server
|
||||||
dockerfile: docker/Dockerfile.server.alpine
|
dockerfile: docker/Dockerfile.server.alpine
|
||||||
secrets: [ docker_username, docker_password ]
|
|
||||||
# TODO: only release as next-alpine after 0.15.0 got released
|
# TODO: only release as next-alpine after 0.15.0 got released
|
||||||
tag: [next-alpine, latest-alpine]
|
tag: [next-alpine, latest-alpine]
|
||||||
when:
|
when:
|
||||||
@ -60,9 +62,10 @@ pipeline:
|
|||||||
publish-agent:
|
publish-agent:
|
||||||
group: bundle
|
group: bundle
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [docker_username, docker_password]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-agent
|
repo: woodpeckerci/woodpecker-agent
|
||||||
dockerfile: docker/Dockerfile.agent
|
dockerfile: docker/Dockerfile.agent
|
||||||
secrets: [docker_username, docker_password]
|
|
||||||
# TODO: only release as next after 0.15.0 got released
|
# TODO: only release as next after 0.15.0 got released
|
||||||
tag: [next, latest]
|
tag: [next, latest]
|
||||||
when:
|
when:
|
||||||
@ -72,9 +75,10 @@ pipeline:
|
|||||||
publish-agent-alpine:
|
publish-agent-alpine:
|
||||||
group: bundle
|
group: bundle
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [ docker_username, docker_password ]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-agent
|
repo: woodpeckerci/woodpecker-agent
|
||||||
dockerfile: docker/Dockerfile.agent.alpine
|
dockerfile: docker/Dockerfile.agent.alpine
|
||||||
secrets: [ docker_username, docker_password ]
|
|
||||||
# TODO: only release as next-alpine after 0.15.0 got released
|
# TODO: only release as next-alpine after 0.15.0 got released
|
||||||
tag: [next-alpine, latest-alpine]
|
tag: [next-alpine, latest-alpine]
|
||||||
when:
|
when:
|
||||||
@ -84,10 +88,11 @@ pipeline:
|
|||||||
publish-cli:
|
publish-cli:
|
||||||
group: docker
|
group: docker
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [docker_username, docker_password]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-cli
|
repo: woodpeckerci/woodpecker-cli
|
||||||
dockerfile: docker/Dockerfile.cli
|
dockerfile: docker/Dockerfile.cli
|
||||||
secrets: [docker_username, docker_password]
|
tag: next
|
||||||
tag: [next]
|
|
||||||
when:
|
when:
|
||||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
event: push
|
event: push
|
||||||
@ -95,10 +100,11 @@ pipeline:
|
|||||||
publish-cli-alpine:
|
publish-cli-alpine:
|
||||||
group: docker
|
group: docker
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [ docker_username, docker_password ]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-cli
|
repo: woodpeckerci/woodpecker-cli
|
||||||
dockerfile: docker/Dockerfile.cli.alpine
|
dockerfile: docker/Dockerfile.cli.alpine
|
||||||
secrets: [ docker_username, docker_password ]
|
tag: next-alpine
|
||||||
tag: [next-alpine]
|
|
||||||
when:
|
when:
|
||||||
branch: ${CI_REPO_DEFAULT_BRANCH}
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
event: push
|
event: push
|
||||||
@ -106,9 +112,10 @@ pipeline:
|
|||||||
release-server:
|
release-server:
|
||||||
group: bundle
|
group: bundle
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [docker_username, docker_password]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-server
|
repo: woodpeckerci/woodpecker-server
|
||||||
dockerfile: docker/Dockerfile.server
|
dockerfile: docker/Dockerfile.server
|
||||||
secrets: [docker_username, docker_password]
|
|
||||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
@ -116,9 +123,10 @@ pipeline:
|
|||||||
release-server-alpine:
|
release-server-alpine:
|
||||||
group: bundle
|
group: bundle
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [ docker_username, docker_password ]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-server
|
repo: woodpeckerci/woodpecker-server
|
||||||
dockerfile: docker/Dockerfile.server.alpine
|
dockerfile: docker/Dockerfile.server.alpine
|
||||||
secrets: [ docker_username, docker_password ]
|
|
||||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
@ -126,9 +134,10 @@ pipeline:
|
|||||||
release-agent:
|
release-agent:
|
||||||
group: bundle
|
group: bundle
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [docker_username, docker_password]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-agent
|
repo: woodpeckerci/woodpecker-agent
|
||||||
dockerfile: docker/Dockerfile.agent
|
dockerfile: docker/Dockerfile.agent
|
||||||
secrets: [docker_username, docker_password]
|
|
||||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
@ -136,9 +145,10 @@ pipeline:
|
|||||||
release-agent-alpine:
|
release-agent-alpine:
|
||||||
group: bundle
|
group: bundle
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [ docker_username, docker_password ]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-agent
|
repo: woodpeckerci/woodpecker-agent
|
||||||
dockerfile: docker/Dockerfile.agent.alpine
|
dockerfile: docker/Dockerfile.agent.alpine
|
||||||
secrets: [ docker_username, docker_password ]
|
|
||||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
@ -146,9 +156,10 @@ pipeline:
|
|||||||
release-cli:
|
release-cli:
|
||||||
group: docker
|
group: docker
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [docker_username, docker_password]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-cli
|
repo: woodpeckerci/woodpecker-cli
|
||||||
dockerfile: docker/Dockerfile.cli
|
dockerfile: docker/Dockerfile.cli
|
||||||
secrets: [docker_username, docker_password]
|
|
||||||
tag: [latest, "${CI_COMMIT_TAG}"]
|
tag: [latest, "${CI_COMMIT_TAG}"]
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
@ -156,9 +167,10 @@ pipeline:
|
|||||||
release-cli-alpine:
|
release-cli-alpine:
|
||||||
group: docker
|
group: docker
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
secrets: [ docker_username, docker_password ]
|
||||||
|
settings:
|
||||||
repo: woodpeckerci/woodpecker-cli
|
repo: woodpeckerci/woodpecker-cli
|
||||||
dockerfile: docker/Dockerfile.cli.alpine
|
dockerfile: docker/Dockerfile.cli.alpine
|
||||||
secrets: [ docker_username, docker_password ]
|
|
||||||
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
@ -174,15 +186,16 @@ pipeline:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
image: plugins/github-release
|
image: plugins/github-release
|
||||||
|
secrets:
|
||||||
|
- source: github_token
|
||||||
|
target: github_release_api_key
|
||||||
|
settings:
|
||||||
files:
|
files:
|
||||||
- dist/*.tar.gz
|
- dist/*.tar.gz
|
||||||
- dist/*.deb
|
- dist/*.deb
|
||||||
- dist/*.rpm
|
- dist/*.rpm
|
||||||
- dist/checksums.txt
|
- dist/checksums.txt
|
||||||
title: ${CI_COMMIT_TAG##v}
|
title: ${CI_COMMIT_TAG##v}
|
||||||
secrets:
|
|
||||||
- source: github_token
|
|
||||||
target: github_release_api_key
|
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
|
|
||||||
|
@ -71,7 +71,10 @@ func sanitizeParamValue(v interface{}) (string, error) {
|
|||||||
return string(out), nil
|
return string(out), nil
|
||||||
|
|
||||||
case reflect.Slice, reflect.Array:
|
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())
|
in := make([]string, vv.Len())
|
||||||
for i := 0; i < vv.Len(); i++ {
|
for i := 0; i < vv.Len(); i++ {
|
||||||
var err error
|
var err error
|
||||||
|
@ -18,6 +18,8 @@ func TestParamsToEnv(t *testing.T) {
|
|||||||
"complex": []struct{ Name string }{{"Jack"}, {"Jill"}},
|
"complex": []struct{ Name string }{{"Jack"}, {"Jill"}},
|
||||||
"complex2": struct{ Name string }{"Jack"},
|
"complex2": struct{ Name string }{"Jack"},
|
||||||
"from.address": "noreply@example.com",
|
"from.address": "noreply@example.com",
|
||||||
|
"tags": stringsToInterface("next", "latest"),
|
||||||
|
"tag": stringsToInterface("next"),
|
||||||
}
|
}
|
||||||
want := map[string]string{
|
want := map[string]string{
|
||||||
"PLUGIN_STRING": "stringz",
|
"PLUGIN_STRING": "stringz",
|
||||||
@ -29,8 +31,18 @@ func TestParamsToEnv(t *testing.T) {
|
|||||||
"PLUGIN_COMPLEX": `[{"name":"Jack"},{"name":"Jill"}]`,
|
"PLUGIN_COMPLEX": `[{"name":"Jack"},{"name":"Jill"}]`,
|
||||||
"PLUGIN_COMPLEX2": `{"name":"Jack"}`,
|
"PLUGIN_COMPLEX2": `{"name":"Jack"}`,
|
||||||
"PLUGIN_FROM_ADDRESS": "noreply@example.com",
|
"PLUGIN_FROM_ADDRESS": "noreply@example.com",
|
||||||
|
"PLUGIN_TAG": "next",
|
||||||
|
"PLUGIN_TAGS": "next,latest",
|
||||||
}
|
}
|
||||||
got := map[string]string{}
|
got := map[string]string{}
|
||||||
assert.NoError(t, paramsToEnv(from, got))
|
assert.NoError(t, paramsToEnv(from, got))
|
||||||
assert.EqualValues(t, want, got, "Problem converting plugin parameters to environment variables")
|
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 {
|
for _, test := range testdata {
|
||||||
in := []byte(test.from)
|
in := []byte(test.from)
|
||||||
@ -182,3 +247,11 @@ func TestUnmarshalContainersErr(t *testing.T) {
|
|||||||
assert.Error(t, err, "wanted error for containers %q", test)
|
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",
|
"description": "Change the settings of your plugin. Read more: https://woodpecker-ci.org/docs/usage/plugins/plugins",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"type": ["boolean", "string", "number"]
|
"type": ["boolean", "string", "number", "array", "object"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user