Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

What are the different status of $BITBUCKET_EXIT_CODE env when after-script is used on pipeline ?

Adrian Garay
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!
August 15, 2019

I have a problem when run my pipeline, I send notifications to users when $BITBUCKET_EXIT_CODE is 1 but It return 2 as value, on doc is only write 0 for success and 1 for error but 2 is not defined

1 answer

0 votes
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 19, 2019

Hi @Adrian Garay

The BITBUCKET_EXIT_CODE variable will save exit code of the last command run by the pipelines script section (After scripts now available for Bitbucket Pipelines).

Let's suppose we have the following bitbucket-pipelines.yml file:

    - step:
        script:
           - not_existing_command
        after-script:
           - echo $BITBUCKET_EXIT_CODE

The script section will try to run the not_existing_command in the terminal and the terminal will return the error 127 (command not found).

The error code will have the context of the command that was run. Keep in mind that some commands may have slightly different exit codes, so the values you see in BITBUCKET_EXIT_CODE need to be interpreted based on the command returning the exit code.

I hope that helps =]

Adrian Garay
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!
September 9, 2019

Thanks a lot Daniel

Like # people like this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 9, 2019

You are welcome @Adrian Garay!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events