Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Why is the dynamic variable not working in my command?

Edited

Hi,

My script works fine when for example the variable 

$ZIP_FILE_NAME in - zip -r $ZIP_FILE_NAME . -x *.git*

is written static like:

- zip -r demo.zip . -x *.git*

However, when I try to use via call to a dynamic variable defined in the global variables of the repository. I have this error in the pipeline: 

The user-provided path demo.zip does not exist.

Can you help? here the script I use:

image: node:6.9.4
pipelines:
default:
-
step:
name: "Zip the code"
script:
-
AWS_ZIP_FILE_DSN_NAME="demo"
-
echo "zip file"
-
apt-get update && apt-get install zip --assume-yes
-
zip -r $ZIP_FILE_NAME . -x *.git*
artifacts: - $ZIP_FILE_NAME
-
step: name: "Push the zip file to S3"
caches: - node
script: - echo "push to s3 bucket"
# install Amazon CLI
-
apt-get update
-
apt-get install -y python --assume-yes
-
apt-get install -y jq
-
curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
-
python get-pip.py - python -m pip install --upgrade "pip < 21.0"
-
pip install awscli - aws configure set default.region eu-west-1
-
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile $AWS_PROFILE_NAME
-
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile $AWS_PROFILE_NAME
-
aws iam get-user - temp_role=$(aws sts assume-role --role-arn $AWS_ROLE_ARN --role-session-name "assumedrole" --profile $AWS_PROFILE_NAME)
-
aws configure set aws_access_key_id $(echo $temp_role | jq .Credentials.AccessKeyId | xargs) --profile $AWS_PROFILE_NAME
-
aws configure set aws_secret_access_key $(echo $temp_role | jq .Credentials.SecretAccessKey | xargs) --profile $AWS_PROFILE_NAME
-
aws configure set aws_session_token $(echo $temp_role | jq .Credentials.SessionToken | xargs) --profile $AWS_PROFILE_NAME
-
aws s3 cp "./$ZIP_FILE_NAME" $AWS_S3_BUCKET --profile $AWS_PROFILE_NAME

 

The error is generated for 

- aws s3 cp "./$ZIP_FILE_NAME" $AWS_S3_BUCKET --profile $AWS_PROFILE_NAME

 

Thanks a lot on advance

Aude F

1 answer

1 accepted

0 votes
Answer accepted

Hi finally managed to have it work. The problem came from the artifacts. They cannot be set with dynamic variables. Code works OK otherwise. May need a few updates.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

233 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you