diff --git a/integration/gcs.go b/integration/gcs.go index a67b5fb00..5d38ed460 100644 --- a/integration/gcs.go +++ b/integration/gcs.go @@ -22,7 +22,6 @@ import ( "log" "os" "os/exec" - "path/filepath" "time" ) @@ -49,16 +48,16 @@ func CreateIntegrationTarball() (string, error) { // UploadFileToBucket will upload the at filePath to gcsBucket. It will return the path // of the file in gcsBucket. -func UploadFileToBucket(gcsBucket string, filePath string) (string, error) { - log.Printf("Uploading file at %s to GCS bucket at %s\n", filePath, gcsBucket) +func UploadFileToBucket(gcsBucket string, filePath string, gcsPath string) (string, error) { + dst := fmt.Sprintf("%s/%s", gcsBucket, gcsPath) + log.Printf("Uploading file at %s to GCS bucket at %s\n", filePath, dst) - cmd := exec.Command("gsutil", "cp", filePath, gcsBucket) - _, err := RunCommandWithoutTest(cmd) - if err != nil { + cmd := exec.Command("gsutil", "cp", filePath, dst) + if _, err := RunCommandWithoutTest(cmd); err != nil { return "", fmt.Errorf("Failed to copy tarball to GCS bucket %s: %s", gcsBucket, err) } - return filepath.Join(gcsBucket, filePath), err + return dst, nil } // DeleteFromBucket will remove the content at path. path should be the full path diff --git a/integration/images.go b/integration/images.go index f194a4033..a207c8794 100644 --- a/integration/images.go +++ b/integration/images.go @@ -26,6 +26,7 @@ import ( "runtime" "strconv" "strings" + "time" "github.com/GoogleContainerTools/kaniko/pkg/timing" ) @@ -195,6 +196,9 @@ func (d *DockerFileBuilder) BuildImage(imageRepo, gcsBucket, dockerfilesPath, do } if b, err := strconv.ParseBool(os.Getenv("BENCHMARK")); err == nil && b { benchmarkEnv = "BENCHMARK_FILE=/kaniko/benchmarks/" + dockerfile + benchmarkFile := path.Join("benchmarks", dockerfile) + dst := path.Join("benchmarks/run_"+time.Now().Format("2006-01-02 15:04:05"), dockerfile) + defer UploadFileToBucket(gcsBucket, benchmarkFile, dst) } // build kaniko image diff --git a/integration/integration_test.go b/integration/integration_test.go index 386c1dfc6..4ffdc663d 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -127,7 +127,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - fileInBucket, err := UploadFileToBucket(config.gcsBucket, contextFile) + fileInBucket, err := UploadFileToBucket(config.gcsBucket, contextFile, contextFile) if err != nil { fmt.Println("Failed to upload build context", err) os.Exit(1)