Replace :env values in :repositories with lookups from environment.
Needed for unattended builds.
This commit is contained in:
parent
2a089a131b
commit
674b4d52ae
3 changed files with 22 additions and 3 deletions
|
@ -77,7 +77,8 @@
|
|||
that didn't have an explicit entry."
|
||||
[[id {:keys [url] :as repo}]]
|
||||
(let [repo-creds (or (user/credentials)
|
||||
(-> (user/profiles) :auth :repository-auth))]
|
||||
(-> (user/profiles) :auth :repository-auth))
|
||||
repo (user/env-auth repo)]
|
||||
(when (-> (user/profiles) :auth :repository-auth)
|
||||
(println "Warning: :repository-auth in the :auth profile is deprecated.")
|
||||
(println "Please use ~/.lein/credentials.clj.gpg instead."))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns leiningen.core.user
|
||||
"Functions exposing user-level configuration."
|
||||
(:require [clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
[clojure.java.shell :as shell]))
|
||||
|
||||
(defn leiningen-home
|
||||
|
@ -21,12 +22,25 @@
|
|||
(catch Exception e
|
||||
(.printStackTrace e))))))))
|
||||
|
||||
(defn profiles []
|
||||
(defn profiles
|
||||
"Load profiles.clj from your Leiningen home if present."
|
||||
[]
|
||||
(let [profiles-file (io/file (leiningen-home) "profiles.clj")]
|
||||
(if (.exists profiles-file)
|
||||
(read-string (slurp profiles-file)))))
|
||||
|
||||
(defn- env-auth-key [settings [k v]]
|
||||
(assoc settings k (if (= :env v)
|
||||
(System/getenv (str "LEIN_" (str/upper-case (name k))))
|
||||
v)))
|
||||
|
||||
(defn env-auth
|
||||
"Replace all :env values in map with LEIN_key environment variables."
|
||||
[settings]
|
||||
(reduce env-auth-key {} settings))
|
||||
|
||||
(defn credentials-fn
|
||||
"Decrypt map from credentials.clj.gpg in Leiningen home if present."
|
||||
([] (let [cred-file (io/file (leiningen-home) "credentials.clj.gpg")]
|
||||
(when (.exists cred-file)
|
||||
(credentials-fn cred-file))))
|
||||
|
|
|
@ -147,7 +147,11 @@
|
|||
;; {:username "milgrim"
|
||||
;; :password "locative.1"}}}}
|
||||
"snapshots" "http://blueant.com/archiva/snapshots"
|
||||
"releases" "http://blueant.com/archiva/internal"}
|
||||
"releases" {:url "http://blueant.com/archiva/internal"
|
||||
;; Using :env as a value here will cause an
|
||||
;; enironment variable to be used based on
|
||||
;; the key; in this case LEIN_PASSWORD.
|
||||
:username "milgrim" :password :env}}
|
||||
;; You can set :update and :checksum policies here to have them
|
||||
;; apply for all :repositories. Usually you will not set :update
|
||||
;; directly but apply the "update" profile instead.
|
||||
|
|
Loading…
Reference in a new issue