Merge pull request #13860 from olemarkus/sha-for-sha

Set Makefile GITSHA to the git sha instead of human 'readable' name
This commit is contained in:
Kubernetes Prow Robot 2022-06-28 21:20:05 -07:00 committed by GitHub
commit 9a3e86ca31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -34,7 +34,7 @@ When a PR builds successfully, you can test the PR using the following script:
```sh
pr=13208
sha=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/kubernetes/kops/pulls/${pr} | jq -r .head.sha )
export KOPS_BASE_URL=https://storage.googleapis.com/kops-ci/pulls/pull-kops-e2e-kubernetes-aws/pull-v1.24.0-alpha.2-68-g8a1070a1b9
export KOPS_BASE_URL="https://storage.googleapis.com/kops-ci/pulls/pull-kops-e2e-kubernetes-aws/pull-${sha}"
wget -q "$KOPS_BASE_URL/$(go env GOOS)/$(go env GOARCH)/kops"
chmod +x ./kops
./kops version

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
}