i setup a CD pipeline for one of my projects that first is using rsync to sync the code to the remote server and then executes a shell script on the remote server through the
atlassian/ssh-run:0.2.7
pipeline.
the shell script on the remote server, among other things, runs the following function:
#define function that will export env vars
function export_envs() {
local envFile=${1:-.env}
while IFS='=' read -r key temp || [ -n "$key" ]; do
local isComment='^[[:space:]]*#'
local isBlank='^[[:space:]]*$'
[[ $key =~ $isComment ]] && continue
[[ $key =~ $isBlank ]] && continue
value=$(eval echo "$temp")
eval export "$key='$value'";
done < $envFile
}
#run the command
export_envs
The thing now is that if the pipeline triggers this shell script, it fails because of this:
/www/htdocs/w01b3634/test/deploy.sh: line 10: .env: No such file or directory
however, if I run the command by hand on the remote server, it does work.
the .env file on the remote server does exist of course...
Any clue what I'm doing wrong?
found it. I had to specify the absolute url of the .env file in the function...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.