Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,058
Community Members
 
Community Events
184
Community Groups

How to get build status in a Bamboo build task script?

Hello,

I would like to call the github API at the end of the build in order to tell him if the build was successfull or not.

I've created a final task for this but I can't find a bamboo variable who contains the build state.

Could you help me?

Thanks :)

Hélène

3 answers

1 accepted

5 votes
Answer accepted

Okay so I found the perfect variable (undocumented) : `bamboo_jobFailed` :)

Exactly what I wanted. Thanks @Hélène_Droal 

Thank you @Hélène_Droal this is going to save me a headache with the API! 

Can someone please share the api, it would be helpful for me.
Iam searching it for past week couldn't able to get the proper one.
Thanks

Github Commit Status API:

https://docs.github.com/en/rest/commits/statuses#create-a-commit-status

Script Task in Bamboo:

REPO="repo-owner/my-repo-name"

if [[ "$bamboo_jobFailed" == "false" ]]
then
    STATE=success
else
    STATE=failure
fi

DATA="{\"state\":\"$STATE\",\"target_url\":\"$bamboo_buildResultsUrl\",\"description\":\"Bamboo build succeeded!\",\"context\":\"default\"}"

curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $bamboo_github_token"\
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$REPO/statuses/$bamboo_repository_revision_number" \
-d "$DATA"

looks like there was a syntax update to reference the variable, example script

${bamboo_jobFailed} instead of $bamboo_jobFailed

 

#!/usr/bin/env bash

## bamboo does not catch some script failures unless this flag is set

set -e

TASK="CHECK BUILD STATUS"

echo ================== START $TASK ==================

## bamboo_jobFailed is a boolean

BUILD_STATUS=${bamboo_jobFailed}

if [[ "$BUILD_STATUS" == "true" ]]

then

echo "the build has failed"

else

echo "the build is passing"

fi

echo =================== END $TASK ===================
0 votes
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Feb 18, 2019

I would suggest to install this plugin: https://github.com/HackAttack/bamboo-github-status

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events