Skip to content

Commit

Permalink
#42: Expose Work ID to script environment (#43)
Browse files Browse the repository at this point in the history
feat(): expose hook ID to script environment
  • Loading branch information
AStevensTaylor committed May 6, 2021
1 parent f29a174 commit d3777a7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/worker/work_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package worker

import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
Expand Down Expand Up @@ -38,7 +39,8 @@ func Run(work *model.WorkRequest) error {
// Exec script with args...
cmd := exec.Command(binary, work.Payload)
// with env variables...
cmd.Env = append(os.Environ(), work.Args...)
workEnv := append(os.Environ(), fmt.Sprintf("hook_id=%d", work.ID))
cmd.Env = append(workEnv, work.Args...)
// using a process group...
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}

Expand Down

0 comments on commit d3777a7

Please sign in to comment.