mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-17 03:45:13 +00:00
Run matrix as default when running docker exec
This commit is contained in:
parent
ae418bf063
commit
46dba4377c
1 changed files with 40 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -13,6 +14,7 @@ import (
|
||||||
"github.com/drone/drone/build/docker"
|
"github.com/drone/drone/build/docker"
|
||||||
"github.com/drone/drone/model"
|
"github.com/drone/drone/model"
|
||||||
"github.com/drone/drone/queue"
|
"github.com/drone/drone/queue"
|
||||||
|
"github.com/drone/drone/yaml"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
|
@ -338,7 +340,7 @@ func exec(c *cli.Context) error {
|
||||||
Pull: c.Bool("pull"),
|
Pull: c.Bool("pull"),
|
||||||
}
|
}
|
||||||
|
|
||||||
payload := queue.Work{
|
payload := &queue.Work{
|
||||||
Yaml: string(file),
|
Yaml: string(file),
|
||||||
Verified: c.BoolT("yaml.verified"),
|
Verified: c.BoolT("yaml.verified"),
|
||||||
Signed: c.BoolT("yaml.signed"),
|
Signed: c.BoolT("yaml.signed"),
|
||||||
|
@ -382,12 +384,45 @@ func exec(c *cli.Context) error {
|
||||||
Status: c.String("prev.build.status"),
|
Status: c.String("prev.build.status"),
|
||||||
Commit: c.String("prev.commit.sha"),
|
Commit: c.String("prev.commit.sha"),
|
||||||
},
|
},
|
||||||
Job: &model.Job{
|
|
||||||
Environment: getMatrix(c),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.Run(&payload, cancelc)
|
if len(c.StringSlice("matrix")) > 0 {
|
||||||
|
p := *payload
|
||||||
|
p.Job = &model.Job{
|
||||||
|
Environment: getMatrix(c),
|
||||||
|
}
|
||||||
|
return a.Run(&p, cancelc)
|
||||||
|
}
|
||||||
|
|
||||||
|
axes, err := yaml.ParseMatrix(file)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(axes) == 0 {
|
||||||
|
axes = append(axes, yaml.Axis{})
|
||||||
|
}
|
||||||
|
|
||||||
|
var jobs []*model.Job
|
||||||
|
count := 0
|
||||||
|
for _, axis := range axes {
|
||||||
|
jobs = append(jobs, &model.Job{
|
||||||
|
Number: count,
|
||||||
|
Environment: axis,
|
||||||
|
})
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, job := range jobs {
|
||||||
|
fmt.Printf("Running Matrix job #%d\n", job.Number)
|
||||||
|
p := *payload
|
||||||
|
p.Job = job
|
||||||
|
if err := a.Run(&p, cancelc); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function to retrieve matrix variables.
|
// helper function to retrieve matrix variables.
|
||||||
|
|
Loading…
Reference in a new issue