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.

1 answer

hey, did you find any solution to this?

Suggest an answer

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

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

4,903 views 4 22
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