Read OS environment variables on application.yml

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Read OS environment variables on application.yml

Rafael Felini
Hi everyone!

    Does anyone knows what I have to do to read an OS environment variables on application.yml?

    I need to read some vars like database user, password, url and ci build number from OS environment variables.

    As Grails is based on Spring Boot, reading through Spring Boot docs http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config it reads from OS environment variables, but apparently it does not apply to Grails. 

    My application.yml is like this snippet:    
    production:
        dataSource:
            driverClassName: com.mysql.jdbc.Driver
            dialect: org.hibernate.dialect.MySQL5InnoDBDialect
            dbCreate: update
            url: ${DB_JDBC_URL}
            username: ${DB_USERNAME}
            password: ${DB_PASSWORD}

Thanks,
Rafael

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/6ef43b4a-13f6-41e9-9402-0044d33a1f89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Read OS environment variables on application.yml

Lucas Videla
Hey Rafael... did you get any responses or workarounds?
I have the same question here :)

Thanks!

On Wednesday, April 8, 2015 at 9:53:16 AM UTC-3, Rafael Felini wrote:
Hi everyone!

    Does anyone knows what I have to do to read an OS environment variables on application.yml?

    I need to read some vars like database user, password, url and ci build number from OS environment variables.

    As Grails is based on Spring Boot, reading through Spring Boot docs <a href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.spring.io%2Fspring-boot%2Fdocs%2Fcurrent%2Freference%2Fhtmlsingle%2F%23boot-features-external-config\46sa\75D\46sntz\0751\46usg\75AFQjCNHw9lmy7GbMHPrx7SssWijTi4Sm1w';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.spring.io%2Fspring-boot%2Fdocs%2Fcurrent%2Freference%2Fhtmlsingle%2F%23boot-features-external-config\46sa\75D\46sntz\0751\46usg\75AFQjCNHw9lmy7GbMHPrx7SssWijTi4Sm1w';return true;">http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config it reads from OS environment variables, but apparently it does not apply to Grails. 

    My application.yml is like this snippet:    
    production:
        dataSource:
            driverClassName: com.mysql.jdbc.Driver
            dialect: org.hibernate.dialect.MySQL5InnoDBDialect
            dbCreate: update
            url: ${DB_JDBC_URL}
            username: ${DB_USERNAME}
            password: ${DB_PASSWORD}

Thanks,
Rafael

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/09636ac1-6bcc-463c-b969-fd7c7c54e6d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Read OS environment variables on application.yml

Rafael Felini
Hi Lucas!

I created a application.groovy file and put all configs that comes from os env var there. I don't like much doing this, but works for now.


On Fri, May 1, 2015 at 11:07 PM Lucas Videla <[hidden email]> wrote:
Hey Rafael... did you get any responses or workarounds?
I have the same question here :)

Thanks!


On Wednesday, April 8, 2015 at 9:53:16 AM UTC-3, Rafael Felini wrote:
Hi everyone!

    Does anyone knows what I have to do to read an OS environment variables on application.yml?

    I need to read some vars like database user, password, url and ci build number from OS environment variables.

    As Grails is based on Spring Boot, reading through Spring Boot docs http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config it reads from OS environment variables, but apparently it does not apply to Grails. 

    My application.yml is like this snippet:    
    production:
        dataSource:
            driverClassName: com.mysql.jdbc.Driver
            dialect: org.hibernate.dialect.MySQL5InnoDBDialect
            dbCreate: update
            url: ${DB_JDBC_URL}
            username: ${DB_USERNAME}
            password: ${DB_PASSWORD}

Thanks,
Rafael

--
You received this message because you are subscribed to a topic in the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grails-dev-discuss/Zxv6EzyrRGY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/09636ac1-6bcc-463c-b969-fd7c7c54e6d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAM5%3D1LSmX-QK0CbQgYYScXycFPVGMo6EQwa84Rq9WcmAtYcaWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Read OS environment variables on application.yml

Tim Hepner
I think you just need quotes.  Here's what I have

    production:
        dataSource:
            url: "${JDBC_CONNECTION_STRING}"
            driverClassName: com.mysql.jdbc.Driver
            username: "${DB_USER}"
            password: "${DB_PASS}"


I found the answer here:

http://se.ecologic.ch/?p=28
Reply | Threaded
Open this post in threaded view
|

Re: Read OS environment variables on application.yml

Daniel Leahy
Hi, 
       link posted is not accessible

Regards,
               Daniel.

On Monday, 19 October 2015 19:57:05 UTC+1, Tim Hepner wrote:
I think you just need quotes.  Here's what I have

    production:
        dataSource:
            url: "${JDBC_CONNECTION_STRING}"
            driverClassName: com.mysql.jdbc.Driver
            username: "${DB_USER}"
            password: "${DB_PASS}"


I found the answer here:

<a href="http://se.ecologic.ch/?p=28" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fse.ecologic.ch%2F%3Fp%3D28\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFNj78N4dyQpQFCt6PfXfRCCiK_IQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fse.ecologic.ch%2F%3Fp%3D28\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFNj78N4dyQpQFCt6PfXfRCCiK_IQ&#39;;return true;">http://se.ecologic.ch/?p=28



--
View this message in context: <a href="http://grails.1312388.n4.nabble.com/Read-OS-environment-variables-on-application-yml-tp4659099p4659827.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fgrails.1312388.n4.nabble.com%2FRead-OS-environment-variables-on-application-yml-tp4659099p4659827.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFnPFHynx4hAuqFMa7SGgCwTMaqXQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fgrails.1312388.n4.nabble.com%2FRead-OS-environment-variables-on-application-yml-tp4659099p4659827.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFnPFHynx4hAuqFMa7SGgCwTMaqXQ&#39;;return true;">http://grails.1312388.n4.nabble.com/Read-OS-environment-variables-on-application-yml-tp4659099p4659827.html
Sent from the Grails Dev Discuss mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/819bd5f9-ded7-4e1e-a570-d0063b5e63d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.