I'm trying to make a complete development to the production pipeline.
In this scenario, I want to have a Jenkins job deploy the Java Spring application once a new commit is done.
An example of some of my applications.propperties is:
spring.datasource.url=jdbc:mariadb://localhost:3306/application-api?serverTimezone=CET
spring.datasource.username=USERNAME
spring.datasource.password=PASSWORD
Once you have this in a git repository your credentials are stored and visual for everyone. I don't have the plan to make anything public yet but seems like a bad idea to store application.properties with passwords on a git repository.
So best case scenario I want something like this, where I can set environment vars on my deployment server:
spring.datasource.username=${DB_PASS}:PASSWORD
In case of environment variable DB_PASS
doesn't exist
I'm stuck on how to achieve this. I have seen the usage of @Value
but I'm unaware of how to use that with given application properties.