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

Bitbucket pipelines variables in curl

Hi everyone,

I'm using bitbucket pipelines and in one step I want to call curl request to our API to save deployment data in DB.

But when I try to call curl with BITBUCKET_BRANCH and BITBUCKET_REPO_SLUG variables they are always empty or not filled at all.

This is my pipeline script:

image: php:7.1.1

pipelines:
branches:
master:
- step:
name: Preparing pipeline
script:
- echo 'Preparing pipeline'

- step:
name: Deploy to dev10
trigger: manual
deployment: staging
script:
- cat ./deploy.sh | ssh root@37.46.85.244
dev1/*:
- step:
name: Preparing pipeline
script:
- echo 'Preparing pipeline'
- export BRANCH=$BITBUCKET_BRANCH
- echo ${BRANCH}
- curl -X POST "http://api.creativehandles.com/api/savePipelineBranch" -H "Content-Type:application/x-www-form-urlencoded" -H "cache-control:no-cache" -H "content-type:multipart/form-data;" -F branch=${BRANCH} -F repository_slug=$BITBUCKET_REPO_SLUG

- step:
name: Deploy to dev1
trigger: manual
deployment: staging
script:
- cat ./deploy_dev1.sh | ssh root@37.46.85.244

You can see that for branches dev1/* I have the first step where I'm calling the curl with 2 variables. I tried two methods of using variables I found on the internet but none of them is working. I every time get the response from curl that variables are empty.

2 answers

You need to escape from character sequence as you would do in terminal. You can find extensive answer on how to do this here: https://superuser.com/questions/835587/how-to-include-environment-variable-in-bash-line-curl 

hey, did you find any solution to this?

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...

179 views 2 4
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