 
 (defonce ^:private test-metrics-run-description
          (System/getenv "TEST_METRICS_RUN_DESCRIPTION"))
+
+(defonce ^:private test-metrics-run-attempt
+         (System/getenv "TEST_METRICS_RUN_ATTEMPT"))
+
+(defonce ^:private test-metrics-failed-tests-file
+         (if-let [given-path (System/getenv "TEST_METRICS_FAILED_TESTS_FILE")]
+           given-path
+           (do
+             (.mkdirs (File. ".test_metrics"))
+             ".test_metrics/last_failed_tests")))
 
 (defonce ^:private git-repo
          (when test-metrics-url
            (try
              (jgit/load-repo (str (System/getProperty "user.dir") "/.."))
              (catch Throwable _
-               (log/warn "Could not get git repo when trying to report test metrics.")))))
+               (log/info "Could not get git repo when trying to report test metrics.")))))
 
 (defonce ^:private current-git-branch
          (when git-repo

                  test-failed? (> (+ num-fails num-errors) 0)
                  result (if test-failed? "failed" (if test-skipped? "skipped" "passed"))
                  es-index (str "waiter-tests-" (du/date-to-str (t/now) (f/formatters :basic-date)))]
              ;TODO: can check for outstanding commits: (println (jgit/git-status git-repo))
              (post-json (str test-metrics-url "/" es-index "/test-result")
                         (json/write-str {:build-id test-metrics-build-id

                 (.setRequestMethod "POST")
                 (.setRequestProperty "content-type" "application/json")
                 (.setUseCaches false)
                 (.setReadTimeout 10000)
                 (.setConnectTimeout 10000)
                 (.connect))]
      (with-open [writer (io/writer (.getOutputStream conn))]
        (.write writer json))
      (.getResponseCode conn))
    (catch Throwable e
      (log/error e "Failed to post test metrics json " url json)
      (throw e))))

(defn blue [message] (str ANSI-BLUE message ANSI-RESET))
