Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

1,000 views 20 11
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