Created
March 13, 2015 06:00
-
-
Save ottbot/8dcbb781069cd6e86357 to your computer and use it in GitHub Desktop.
Get the number of builds made on Circle CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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