Use PULL_PULL_SHA as gcs location sha if available

This commit is contained in:
Ole Markus With 2022-06-28 20:23:30 +02:00
parent e34335fd43
commit d5372e7387
1 changed files with 11 additions and 8 deletions

View File

@ -92,14 +92,17 @@ func defaultStageLocation(kopsRoot string) (string, error) {
jobName = defaultJobName
}
cmd := exec.Command("git", "rev-parse", "--short", "HEAD")
cmd.SetDir(kopsRoot)
output, err := exec.CombinedOutputLines(cmd)
if err != nil {
return "", err
} else if len(output) != 1 {
return "", fmt.Errorf("unexpected output from git describe: %v", output)
sha := os.Getenv("PULL_PULL_SHA")
if sha == "" {
cmd := exec.Command("git", "rev-parse", "--short", "HEAD")
cmd.SetDir(kopsRoot)
output, err := exec.CombinedOutputLines(cmd)
if err != nil {
return "", err
} else if len(output) != 1 {
return "", fmt.Errorf("unexpected output from git describe: %v", output)
}
sha = strings.TrimSpace(output[0])
}
sha := strings.TrimSpace(output[0])
return fmt.Sprintf(defaultGCSPath, jobName, sha), nil
}