0

I start my application using a shell script. in this script i define the values of some variables depending to the detected environment (dev / prod...)

Then I need to use these variables in the springBoot properties yml.

this is my shell script:

#!/bin/bash

ENV_1="env1"
ENV_2="env2"

export projectBaseUrl=

if [ "$environment" == "$ENV_1" ];
then
  echo "test here"
   projectBaseUrl="https://test"
   echo "projectBaseUrl ${projectBaseUrl} "

elif [ "$environment" == "$ENV_2" ];
then
  echo "test 2 here"
   projectBaseUrl="https://test2"
   echo "projectBaseUrl ${projectBaseUrl} "
fi

in the properties file (yml)

project.ws.baseUrl: ${projectBaseUrl}

in the start.sh logs i cann see that projectBaseUrl has the correct value but in the start of the application i have an error

Could not resolve placeholder 'project.ws.baseUrl' in value "${project.ws.baseUrl}"

Any help please ?

RZH
  • 1
  • 1
  • Run the script in the current shell environment: `. ./script.sh` (see [this question](https://stackoverflow.com/questions/1464253/global-environment-variables-in-a-shell-script)). – Turing85 Jun 18 '23 at 10:10
  • Another alternative is to run the application from within the script. If we want to preserve the process-id, we can use [`exec` (`die.net`)](https://linux.die.net/man/1/exec) – Turing85 Jun 18 '23 at 10:19
  • Your script does not start your application, so how is your application going to pick up the variables that were set in an unrelated (non-parent) process? – knittl Jun 18 '23 at 16:42

0 Answers0