Merge "Add BUILD_USERNAME and BUILD_HOSTNAME"
This commit is contained in:
commit
20a8856c8f
1 changed files with 18 additions and 0 deletions
|
@ -18,6 +18,8 @@ import (
|
|||
"crypto/md5"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
@ -96,6 +98,22 @@ func runKati(ctx Context, config Config, extraSuffix string, args []string, envF
|
|||
|
||||
envFunc(cmd.Environment)
|
||||
|
||||
if _, ok := cmd.Environment.Get("BUILD_USERNAME"); !ok {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
ctx.Println("Failed to get current user")
|
||||
}
|
||||
cmd.Environment.Set("BUILD_USERNAME", u.Username)
|
||||
}
|
||||
|
||||
if _, ok := cmd.Environment.Get("BUILD_HOSTNAME"); !ok {
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
ctx.Println("Failed to read hostname")
|
||||
}
|
||||
cmd.Environment.Set("BUILD_HOSTNAME", hostname)
|
||||
}
|
||||
|
||||
cmd.StartOrFatal()
|
||||
status.KatiReader(ctx.Status.StartTool(), pipe)
|
||||
cmd.WaitOrFatal()
|
||||
|
|
Loading…
Reference in a new issue