Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to set bash directory for script

Shlomo Heigh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 15, 2025

I'm trying to create a custom Pipe that creates a bash script in the 

BITBUCKET_PIPE_STORAGE_DIR directory which a later step in the pipeline can call. I am creating two files in the directory: a script file, and a data file which the script will read from. However, when I try to run the script in the later step, I run into an issue where even if I run the script from it's containing directory, it can't read the data file which is next to it in the same directory. It seems that the script is always using some temp directory as the working directory, even when using `dirname "$0"`.
# Ideally this would be `cd BITBUCKET_SHARED_STORAGE_DIR/...` but that env var isn't available, so we need to hardcode the path:
$ cd /opt/atlassian/pipelines/agent/build/.bitbucket/pipelines/generated/pipeline/pipes/my-org/custom-pipe-name
$ ls
> script.sh data
$ . ./script.sh
> bash: /opt/atlassian/pipelines/agent/tmp/data: No such file or directory
 

The script file contains the following code:

#!/usr/bin/env bash
set -a
path="$(dirname "$0")"
source "$path/data"
set +a

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events