Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
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
View
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."))
View
16 leiningen-core/src/leiningen/core/user.clj
@@ -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))))
View
6 sample.project.clj
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.