简体   繁体   English

lein test with-profile无法覆盖测试配置文件的环境值

[英]lein test with-profile unable to override test profile's env value

I am doing some Clojure pet project. 我正在做一些Clojure宠物项目。 I have some profiles like the following 我有一些如下配置文件

{:test   {:env {:database-name     "library_test",
                :host-name         "192.168.33.10"
                :username          "library_admin"
                :password          ""
                :dbtype            "postgres"
                :driver-class-name "org.postgresql.Driver"}},
 :dev    {:env {:database-name     "library",
                :host-name         "192.168.33.10"
                :username          "library_admin"
                :password          ""
                :dbtype            "postgres"
                :driver-class-name "org.postgresql.Driver"}},
 :travis {:env {:database-name     "test_library_test",
                :host-name         "localhost"
                :username          "test_user"
                :password          "password"
                :dbtype            "postgres"
                :driver-class-name "org.postgresql.Driver"}}}

Now I am trying to setup Travis-CI for the project. 现在,我正在尝试为该项目设置Travis-CI。 I want to override the value of test profile CI while running test, for that I am using the following command 我想在运行测试时覆盖测试配置文件CI的值,因为我正在使用以下命令

lein with-profile travis test 莱因-特拉维斯测验

Here lein is activating the travis profile but it's picking up the environment variables value from test profile instead of travis profile. lein在这里激活travis概要文件,但是它是从测试概要文件而不是travis概要文件中获取环境变量值。

Did anyone face such issues? 有人遇到过这样的问题吗?

Why: Lein merges test profile by default. 原因:Lein默认情况下合并test配置文件 You can see the effective project map with lein with-profile travis,test pprint 您可以使用lein with-profile travis,test pprint查看有效的项目图lein with-profile travis,test pprint

Solution: I assume you're using environ or something like that. 解决方案:我假设您正在使用environ或类似的工具。 If so, you can export values with env in UPCASE_WITH_UNDERSCORE (eg DATABASE_NAME=test_library_test ) and they will override values in profiles 如果是这样,您可以在UPCASE_WITH_UNDERSCORE中用env导出值(例如DATABASE_NAME=test_library_test ),它们将覆盖配置文件中的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM