How can I get branch name in bitbucket-pipeline.yml file

Khánh Phan
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!
March 12, 2018

Hi all,

I have a config file looks like this:

 

image: myimg
pipelines:
   branches:
      release/*:
          - step:

                - script: 

                     - // I want to get branch name here, to pull exacly the branch name when deploy

Is there anyway to do that? Please help

1 answer

7 votes
davina
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2018

Hi,

Pipelines provides default environment variables you can access in your configuration.

For your case specifically:

- script:
- echo $BITBUCKET_BRANCH

For the full list, see the documentation.

 

Hope this helps!

Timothy Reaves
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!
November 17, 2018

That prints $BITBUCKET_BRANCH, not the actual name of the branch.

Like Peter Madsen likes this
Ehsan Korhani
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!
June 30, 2019

If you see something like this:
+ echo $BITBUCKET_BRANCH

that is the command line.
The actual output will print below this line and without the + sign.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events