   (let [metrics (jenkins/collect-metrics (jenkins/http-source (:credentials config)) (:url config))]
     (doall (map #(store/put-document % mapping) metrics))))
 
-(def collector-details
-  {:name    "jenkins-collector"
-   :version (util/get-project-version 'kuona-jenkins-collector)})
-
 (defn collector-log
   "Posts details of the collector to the API server to record the collector run"
   [api-url collector-details parameters status]

    (http/post url body)))


(defn log-collection [api-url collector-details params f]
  (try+
   (collector-log api-url collector-details params :started)
   
   (f)
   
   (collector-log api-url collector-details params :stopped)
   (catch Object _
     (collector-log api-url collector-details params :failed))))


(defn -main
  [& args]
  (let [config            (cli/configure "Kuona Jenkins build collector." cli-options args)
        username          (-> config :username)
        password          (-> config :password)
        build-server      (-> config :jenkins)
        api-url           (-> config :api-url)
        source            (jenkins/http-source {:username username :password password})
        collector-details {:name "jenkins-collector" :version (util/get-project-version 'kuona-jenkins-collector)}]

    (log/info "Collecting metrics from:" build-server)

    (log-collection api-url
                    collector-details
                    [{:api api-url} {:build-server build-server}]
                    #(jenkins/collect-metrics source
                                              build-server
                                              api-url))))

