-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow environment configuration override via Java System Properties or Environment Variables #114
Comments
Hi @hbobenicio , @h3adache , |
Yes @harawata my
In gradle I use:
Which allows me to replace those values using properties defined in my gradle file (I use a separate environments.gradle file) and also allows me to override using command line (system properties) to the gradle build. Maven supports something very similar. I switched away from maven a while ago so I don't have the examples but they look pretty much the same on the properties file. |
Thank you for the explanation, @h3adache ! @hbobenicio , p.s. |
In my case, I'm using the migrations-maven-plugin. Anyway... just thought it would be nice to have support for another direct way to define those properties BTW, I got it working in my case with a workaround on my CI pipeline like: echo "url=$URL" >> my-mybatis-environment.properties
echo "username=$USERNAME" >> my-mybatis-environment.properties
echo "password=$PASSWORD" >> my-mybatis-environment.properties
mvn migration:up -Dmigration.env=my-mybatis-environment @harawata , |
Migrations or migrations-maven-plugin itself does not provide filtering (i.e. variable substitution). And thanks for the links. |
thanks for the tip @harawata ! Well then... you guys can tell if this may be a nice desirable feature or if this runs out of the scope of the project. In case of the later, I'm ok about closing this issue. Once again, thanks for all the tips! |
You're welcome! Regarding the enhancement idea, I'm not opposed to it. |
Hi @hbobenicio and @harawata! Sorry for the late response. Yes the filtering is exactly what I use. |
Hi @h3adache, any chance you could expand on how you use gradle to replace the tokens in your environment file. I am trying to do the same (or at least similar) and having no luck. I have a ci.properties which contains the following Am just wanting to use a dynamic DB name within our CI environment. Ideally I'd like to use a custom task, which populates the above token with a command line property and then run the migrateUp task. But no matter what I do, the token in not replaced and hence connection fails. This is probably down to my lack of gradle knowledge, so any help would be appreciated. Think the difference is that you are using environment variables |
I'm not sure if I got it right but... the only way to configure migrations environments is via a Properties File (for example: ./enviroment/someEnv.properties). Am I correct? (at least I didn't find more on that on the docs page )
If so, it would be also interesting to configure some of the environment properties (or override them) via CLI arguments, Java System Properties or Environment Variables.
for exemple:
Today:
migrate --path=path/to/repo --env=myenv
-> requires full configuration onpath/to/repo/repositories/myenv.properties
Maybe a more flexible alternative:
(
path/to/repo/repositories/myenv.properties
without url, username and password properties)migrate --path=path/to/repo --env=myenv --url=$MYENV_URL --username=$MYENV_USERNAME --password=$MYENV_PASSWORD
or
migrate --path=path/to/repo --env=myenv -Durl=$MYENV_URL -Dusername=$MYENV_USERNAME -Dpassword=$MYENV_PASSWORD
or
env URL=$MYENV_URL USERNAME=$MYENV_USERNAME PASSWORD=$MYENV_PASSWORD migrate --path=path/to/repo --env=myenv
Motivation:
In some deployment environments, a safe approach of storing sensitive data (like db username/password) is via protected environment variables. This way, one would let url, username and password properties out of the environment property file and define it as OS Environment Variable to allow migrations to execute on the CI pipeline.
Sorry for the long description. Any thoughts about it? Is this already possible to be accomplished somehow?
The text was updated successfully, but these errors were encountered: