Passing environment variables to Java Flexible Via Gradle

445 views
Skip to first unread message

E EE

unread,
May 10, 2017, 9:02:29 PM5/10/17
to Google App Engine

The app I build has a dev and prod versions (like most apps).

 

I need a way to specify which version will upload via an environment variable (springboot "profile")

 

The only way I can pass environment variables to a war file is via app.yaml.

This means that the build (gradle) has to change one line in app.yaml as part of the build. The variable name in command line is  --spring.profiles.active, so in app.yaml it will be :


 env_variables:
 
- --spring.profiles.active: ${active_profile}

  • How to you add an environment variable in app.yaml whose value is set by gradle at build time?
  • Is there any other way to achieve this (multiple spring profiles)
  • How to you guys (other flex users) configure different environments of the same app?

George (Cloud Platform Support)

unread,
May 11, 2017, 4:50:57 PM5/11/17
to Google App Engine
If you use Spring Boot, there are various ways of choosing which build version, dev or prod, is getting built, as described in the "24. Externalized Configuration" sub-chapter of the "Spring Boot Reference Guide" online document. [1]

More details and examples can be found on the "Spring Boot : External Configurations for Spring Boot" page. [2]

This discussion group is meant as an environment favorable to expressing general opinions, discussing trends and issues of general nature touching the app engine. If you look for coding and programming architecture advice, you may be at an advantage in a forum such as stackoverflow, where experienced programmers are within reach and ready to help. 

E EE

unread,
May 11, 2017, 5:12:04 PM5/11/17
to Google App Engine
My questions are general, I mention spring just to give some context.

The question is how do you change the variables between different environments (dev / production). The gradle app engine plugin is something I consider part of app engine.

Maybe its better to start a new question thread with no mention of spring or even java.

George (Cloud Platform Support)

unread,
May 12, 2017, 3:15:24 PM5/12/17
to Google App Engine
Your questions were specific initially, and the title of the post mentions Gradle. 

There are various way to configure parameters for startup, generally, a relevant question can be read on stackoverflow, "Can I use a single war file in multiple environments? Should I?". 

With reference to Gradle, you may read "Gradle pass cmd line argument to war".  Both questions are general and do not relate specifically to Google's Cloud Platform. 
Reply all
Reply to author
Forward
0 new messages