-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.clj
29 lines (25 loc) · 1.09 KB
/
api.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(ns monkey.ci.build.api
"Functions for invoking the script API."
(:require [clojure.tools.logging :as log]
[martian.core :as martian]
[monkey.ci.build :as b]))
(def rt->api-client (comp :client :api))
(defn- fetch-params* [rt]
(let [client (rt->api-client rt)
[cust-id repo-id] (b/get-sid rt)]
(log/debug "Fetching repo params for" cust-id repo-id)
(->> @(client {:url (format "/customer/%s/repo/%s/param" cust-id repo-id)
:method :get})
(map (juxt :name :value))
(into {}))))
;; Use memoize because we'll only want to fetch them once
(def build-params (memoize fetch-params*))
(defn download-artifact
"Downloads the artifact with given id for the current job. Returns an input
stream that can then be written to disk, or unzipped using archive functions."
[rt id]
(let [client (rt->api-client rt)
sid (b/get-sid rt)]
(log/debug "Downloading artifact for build" sid ":" id)
@(client {:url (apply format "/customer/%s/repo/%s/builds/%s/artifact/%s/download" (conj sid id))
:method :get})))