mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 00:46:30 +00:00
Fix cli matrix filter (#311)
Using `when` (Conditional Execution) with `matrix` did not work, fix it.
This commit is contained in:
parent
5653577d7e
commit
d802fdb26d
1 changed files with 3 additions and 21 deletions
|
@ -6,7 +6,6 @@ import (
|
|||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
@ -318,7 +317,7 @@ func execWithAxis(c *cli.Context, axis matrix.Axis) error {
|
|||
file = ".drone.yml"
|
||||
}
|
||||
|
||||
metadata := metadataFromContext(c)
|
||||
metadata := metadataFromContext(c, axis)
|
||||
environ := metadata.Environ()
|
||||
secrets := []compiler.Secret{}
|
||||
for k, v := range metadata.EnvironDrone() {
|
||||
|
@ -332,12 +331,6 @@ func execWithAxis(c *cli.Context, axis matrix.Axis) error {
|
|||
})
|
||||
}
|
||||
|
||||
if len(axis) != 0 {
|
||||
for k, v := range axis {
|
||||
environ[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
droneEnv := make(map[string]string)
|
||||
for _, env := range c.StringSlice("env") {
|
||||
envs := strings.SplitN(env, "=", 2)
|
||||
|
@ -434,7 +427,7 @@ func execWithAxis(c *cli.Context, axis matrix.Axis) error {
|
|||
}
|
||||
|
||||
// return the metadata from the cli context.
|
||||
func metadataFromContext(c *cli.Context) frontend.Metadata {
|
||||
func metadataFromContext(c *cli.Context, axis matrix.Axis) frontend.Metadata {
|
||||
return frontend.Metadata{
|
||||
Repo: frontend.Repo{
|
||||
Name: c.String("repo-name"),
|
||||
|
@ -488,7 +481,7 @@ func metadataFromContext(c *cli.Context) frontend.Metadata {
|
|||
},
|
||||
Job: frontend.Job{
|
||||
Number: c.Int("job-number"),
|
||||
Matrix: availableEnvironment(),
|
||||
Matrix: axis,
|
||||
},
|
||||
Sys: frontend.System{
|
||||
Name: c.String("system-name"),
|
||||
|
@ -498,17 +491,6 @@ func metadataFromContext(c *cli.Context) frontend.Metadata {
|
|||
}
|
||||
}
|
||||
|
||||
func availableEnvironment() map[string]string {
|
||||
result := make(map[string]string, 0)
|
||||
|
||||
for _, env := range os.Environ() {
|
||||
pair := strings.SplitN(env, "=", 2)
|
||||
result[pair[0]] = pair[1]
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func convertPathForWindows(path string) string {
|
||||
base := filepath.VolumeName(path)
|
||||
if len(base) == 2 {
|
||||
|
|
Loading…
Reference in a new issue