mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
Supporting multiple yamls in procBuilder
This commit is contained in:
parent
8199fe4a21
commit
c9f2346c2c
4 changed files with 113 additions and 124 deletions
|
@ -323,7 +323,7 @@ func PostApproval(c *gin.Context) {
|
|||
Secs: secs,
|
||||
Regs: regs,
|
||||
Link: httputil.GetURL(c.Request),
|
||||
Yaml: conf.Data,
|
||||
Yamls: []string{conf.Data},
|
||||
Envs: envs,
|
||||
}
|
||||
buildItems, err := b.Build()
|
||||
|
@ -512,7 +512,7 @@ func PostBuild(c *gin.Context) {
|
|||
Secs: secs,
|
||||
Regs: regs,
|
||||
Link: httputil.GetURL(c.Request),
|
||||
Yaml: conf.Data,
|
||||
Yamls: []string{conf.Data},
|
||||
Envs: buildParams,
|
||||
}
|
||||
buildItems, err := b.Build()
|
||||
|
|
|
@ -235,7 +235,7 @@ func PostHook(c *gin.Context) {
|
|||
Regs: regs,
|
||||
Envs: envs,
|
||||
Link: httputil.GetURL(c.Request),
|
||||
Yaml: conf.Data,
|
||||
Yamls: []string{conf.Data},
|
||||
}
|
||||
buildItems, err := b.Build()
|
||||
if err != nil {
|
||||
|
|
|
@ -32,11 +32,12 @@ bbb`,
|
|||
Secs: []*model.Secret{},
|
||||
Regs: []*model.Registry{},
|
||||
Link: "",
|
||||
Yaml: `pipeline:
|
||||
Yamls: []string{`pipeline:
|
||||
xxx:
|
||||
image: scratch
|
||||
yyy: ${DRONE_COMMIT_MESSAGE}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := b.Build(); err != nil {
|
||||
|
|
|
@ -39,7 +39,7 @@ type procBuilder struct {
|
|||
Secs []*model.Secret
|
||||
Regs []*model.Registry
|
||||
Link string
|
||||
Yaml string
|
||||
Yamls []string
|
||||
Envs map[string]string
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,10 @@ type buildItem struct {
|
|||
}
|
||||
|
||||
func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||
var items []*buildItem
|
||||
|
||||
axes, err := matrix.ParseString(b.Yaml)
|
||||
for _, y := range b.Yamls {
|
||||
axes, err := matrix.ParseString(y)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -60,7 +62,6 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
|||
axes = append(axes, matrix.Axis{})
|
||||
}
|
||||
|
||||
var items []*buildItem
|
||||
for i, axis := range axes {
|
||||
proc := &model.Proc{
|
||||
BuildID: b.Curr.ID,
|
||||
|
@ -91,7 +92,6 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
|||
})
|
||||
}
|
||||
|
||||
y := b.Yaml
|
||||
s, err := envsubst.Eval(y, func(name string) string {
|
||||
env := environ[name]
|
||||
if strings.Contains(env, "\n") {
|
||||
|
@ -161,19 +161,6 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
|||
compiler.WithMetadata(metadata),
|
||||
).Compile(parsed)
|
||||
|
||||
// for _, sec := range b.Secs {
|
||||
// if !sec.MatchEvent(b.Curr.Event) {
|
||||
// continue
|
||||
// }
|
||||
// if b.Curr.Verified || sec.SkipVerify {
|
||||
// ir.Secrets = append(ir.Secrets, &backend.Secret{
|
||||
// Mask: sec.Conceal,
|
||||
// Name: sec.Name,
|
||||
// Value: sec.Value,
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
|
||||
item := &buildItem{
|
||||
Proc: proc,
|
||||
Config: ir,
|
||||
|
@ -185,6 +172,7 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
|||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
|
||||
return items, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue