mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-24 16:18:42 +00:00
global environment parameters
This commit is contained in:
parent
b66bdd46b7
commit
f3c06a8fc3
4 changed files with 10 additions and 11 deletions
|
@ -20,6 +20,8 @@ type Context struct {
|
||||||
Keys *common.Keypair `json:"keys"`
|
Keys *common.Keypair `json:"keys"`
|
||||||
Netrc *common.Netrc `json:"netrc"`
|
Netrc *common.Netrc `json:"netrc"`
|
||||||
Yaml []byte `json:"yaml"`
|
Yaml []byte `json:"yaml"`
|
||||||
|
Env []string `json:"env"`
|
||||||
|
|
||||||
Conf *common.Config `json:"-"`
|
Conf *common.Config `json:"-"`
|
||||||
infos []*dockerclient.ContainerInfo
|
infos []*dockerclient.ContainerInfo
|
||||||
client dockerclient.Client
|
client dockerclient.Client
|
||||||
|
@ -126,16 +128,6 @@ func execCompose(c *Context) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func trace(s string) string {
|
|
||||||
cmd := fmt.Sprintf("$ %s\n", s)
|
|
||||||
encoded := base64.StdEncoding.EncodeToString([]byte(cmd))
|
|
||||||
return fmt.Sprintf("echo %s | base64 --decode\n", encoded)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newline(s string) string {
|
|
||||||
return fmt.Sprintf("%s\n", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func runSteps(c *Context, steps map[string]*common.Step) (int, error) {
|
func runSteps(c *Context, steps map[string]*common.Step) (int, error) {
|
||||||
for _, step := range steps {
|
for _, step := range steps {
|
||||||
|
|
||||||
|
@ -151,6 +143,10 @@ func runSteps(c *Context, steps map[string]*common.Step) (int, error) {
|
||||||
|
|
||||||
conf := toContainerConfig(step)
|
conf := toContainerConfig(step)
|
||||||
conf.Cmd = toCommand(c, step)
|
conf.Cmd = toCommand(c, step)
|
||||||
|
|
||||||
|
// append global environment variables
|
||||||
|
conf.Env = append(conf.Env, c.Env)
|
||||||
|
|
||||||
info, err := run(c.client, conf, step.Pull)
|
info, err := run(c.client, conf, step.Pull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 255, err
|
return 255, err
|
||||||
|
|
|
@ -15,6 +15,7 @@ type Work struct {
|
||||||
Keys *common.Keypair `json:"keypair"`
|
Keys *common.Keypair `json:"keypair"`
|
||||||
Netrc *common.Netrc `json:"netrc"`
|
Netrc *common.Netrc `json:"netrc"`
|
||||||
Yaml []byte `json:"yaml"`
|
Yaml []byte `json:"yaml"`
|
||||||
|
Env []string `json:"env"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// represents a worker that has connected
|
// represents a worker that has connected
|
||||||
|
|
|
@ -118,6 +118,7 @@ func (r *Runner) Run(w *queue.Work) error {
|
||||||
Netrc: w.Netrc,
|
Netrc: w.Netrc,
|
||||||
Yaml: w.Yaml,
|
Yaml: w.Yaml,
|
||||||
Build: task,
|
Build: task,
|
||||||
|
Env: w.Env,
|
||||||
}
|
}
|
||||||
in, err := json.Marshal(work)
|
in, err := json.Marshal(work)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -58,6 +58,7 @@ type work struct {
|
||||||
Keys *common.Keypair `json:"keys"`
|
Keys *common.Keypair `json:"keys"`
|
||||||
Netrc *common.Netrc `json:"netrc"`
|
Netrc *common.Netrc `json:"netrc"`
|
||||||
Yaml []byte `json:"yaml"`
|
Yaml []byte `json:"yaml"`
|
||||||
|
Env []string `json:"env"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type worker struct {
|
type worker struct {
|
||||||
|
|
Loading…
Reference in a new issue