Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

no such file or directory when executing shell script through ssh-run pipe

Leonhard Brunner November 26, 2020

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?

1 answer

1 accepted

0 votes
Answer accepted
Leonhard Brunner November 27, 2020

found it. I had to specify the absolute url of the .env file in the function...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events