Skip to content

Instantly share code, notes, and snippets.

@ottbot
Created March 13, 2015 06:00
Show Gist options
  • Save ottbot/8dcbb781069cd6e86357 to your computer and use it in GitHub Desktop.
Save ottbot/8dcbb781069cd6e86357 to your computer and use it in GitHub Desktop.
Get the number of builds made on Circle CI
(require '[clj-http.client :as client])
(def token "a-token")
(defn fetch-projects []
(:body
(client/get "https://circleci.com/api/v1/projects"
{:query-params {"circle-token" token}
:accept :json
:as :json})))
(defn last-build-number [branch]
(get-in branch [:recent_builds 0 :build_num] 0))
(defn build-count [project]
(reduce max (map last-build-number (vals (:branches project)))))
(defn total-builds []
(reduce + (map build-count (fetch-projects))))
;; user> (total-builds)
;; 16721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment