diff --git a/cli/exec/exec.go b/cli/exec/exec.go index 59bbe47e6d..f532208cf6 100644 --- a/cli/exec/exec.go +++ b/cli/exec/exec.go @@ -25,6 +25,7 @@ import ( "strings" "github.com/drone/envsubst" + "github.com/oklog/ulid/v2" "github.com/rs/zerolog/log" "github.com/urfave/cli/v3" @@ -170,6 +171,9 @@ func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, ax return err } + // emulate server behavior https://github.com/woodpecker-ci/woodpecker/blob/eebaa10d104cbc3fa7ce4c0e344b0b7978405135/server/pipeline/stepbuilder/stepBuilder.go#L289-L295 + prefix := "wp_" + ulid.Make().String() + // configure volumes for local execution volumes := c.StringSlice("volumes") if c.Bool("local") { @@ -184,7 +188,7 @@ func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, ax workspacePath = c.String("workspace-path") } - volumes = append(volumes, c.String("prefix")+"_default:"+workspaceBase) + volumes = append(volumes, prefix+"_default:"+workspaceBase) volumes = append(volumes, repoPath+":"+path.Join(workspaceBase, workspacePath)) } @@ -221,9 +225,7 @@ func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, ax compiler.WithNetworks( c.StringSlice("network")..., ), - compiler.WithPrefix( - c.String("prefix"), - ), + compiler.WithPrefix(prefix), compiler.WithProxy(compiler.ProxyOptions{ NoProxy: c.String("backend-no-proxy"), HTTPProxy: c.String("backend-http-proxy"), diff --git a/cli/exec/flags.go b/cli/exec/flags.go index 2bb54fdb8b..c7a985d692 100644 --- a/cli/exec/flags.go +++ b/cli/exec/flags.go @@ -48,13 +48,6 @@ var flags = []cli.Flag{ Name: "network", Usage: "external networks", }, - &cli.StringFlag{ - Sources: cli.EnvVars("WOODPECKER_PREFIX"), - Name: "prefix", - Value: "woodpecker", - Usage: "prefix used for containers, volumes, networks, ... created by woodpecker", - Hidden: true, - }, &cli.StringSliceFlag{ Sources: cli.EnvVars("WOODPECKER_PLUGINS_PRIVILEGED"), Name: "plugins-privileged",