Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Replace :env values in :repositories with lookups from environment.

Needed for unattended builds.
  • Loading branch information...
commit 674b4d52ae277866c454b1f736d0818af2c63a0a 1 parent 2a089a1
@technomancy authored
3  leiningen-core/src/leiningen/core/classpath.clj
@@ -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."))
16 leiningen-core/src/leiningen/core/user.clj
@@ -1,6 +1,7 @@
(ns leiningen.core.user
"Functions exposing user-level configuration."
(:require [ :as io]
+ [clojure.string :as str]
[ :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))))
6 sample.project.clj
@@ -147,7 +147,11 @@
;; {:username "milgrim"
;; :password "locative.1"}}}}
"snapshots" ""
- "releases" ""}
+ "releases" {:url ""
+ ;; 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.
Please sign in to comment.
Something went wrong with that request. Please try again.