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,6 +92,8 @@ func defaultStageLocation(kopsRoot string) (string, error) {
jobName = defaultJobName
}
sha := os.Getenv("PULL_PULL_SHA")
if sha == "" {
cmd := exec.Command("git", "rev-parse", "--short", "HEAD")
cmd.SetDir(kopsRoot)
output, err := exec.CombinedOutputLines(cmd)
@ -100,6 +102,7 @@ func defaultStageLocation(kopsRoot string) (string, error) {
} 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
}