Is there a way to know in a plan's final stage the build status?

yogev ch
Contributor
September 23, 2024

I want to perform some cleaning of an external resource, so I've created a stage, which is a final stage of a plan.
According to Bamboo it should run no matter what.

Is there a way to know in that final stage, if all stages until that stage succeeded or at least one failed?

1 answer

1 accepted

3 votes
Answer accepted
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 23, 2024

Hello Yogev,

Welcome to Atlassian community

You can look at the Buildresult of that run and see what stages passed and what failed, in this particular run, we can see Stage 2 Job 2 failed and Final stage was run successfully. 

image.png

Regards,

Shashank Kumar

**please don't forget to Accept the answer if your query was answered**

yogev ch
Contributor
September 24, 2024

Thanks for your response.

Maybe I didn't clarify myself: I meant that I want to check programmatically in a script task of the final stage, if the build failed or not.

I want to be able to perform some cleanups in case the build failed, automatically in a task within the final stage.

Like Steffen Opel _Utoolity_ likes this
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2024

Hello Yogev,

You can use the REST API to get the details, refer api-api-latest-result-projectkey-buildkey-get for more details.

You'll need to use the expand parameter for stages, see example below

image.png

The result would look something like below when you expand the stages, it would print the status of the stage and you can see if your previous stage was successful or failed.

 

image.png
Regards,
Shashank Kumar
yogev ch
Contributor
September 24, 2024

Thank you
Hmm, for some reason I get

curl: (56) Recv failure: Connection reset by peer

My request is

curl -X GET -H 'Authorization: Bearer Mddd' -H 'Accept: application/json' --url 'http://bamboo:8085/rest/api/latest/result/PPP-AO-123?expand=stages'

 

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2024

Seems to be a network/Proxy/Firewall Issue, Have a read at at https://github.com/curl/curl/issues/1016

Regards,

Shashank Kumar

yogev ch
Contributor
September 24, 2024

Thanks. I think it doesn't help though.

Because this one (without a build number) does work.

curl -X GET -H 'Authorization: Bearer Mddd' -H 'Accept: application/json' --url 'http://bamboo:8085/rest/api/latest/result/PPP-AO?expand=stages'
{
"results": {
"size": 25,
"start-index": 0,
"max-result": 25
},
"expand": "results",
"link": {
"href": "http://bamboo:8085/rest/api/latest/result/PPP-AO",
"rel": "self"
}
}

 

Like Steffen Opel _Utoolity_ likes this
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2024

Hello Yogev,

It won't work without the build number, because you are trying to fetch the results data which is available per build.

You can use bamboo.buildNumber variable to pass to the API, read Bamboo variables for more details

Regards,

Shashank Kumar

yogev ch
Contributor
September 25, 2024

In my last response when I added the example

curl -X GET -H 'Authorization: Bearer Mddd' -H 'Accept: application/json' --url 'http://bamboo:8085/rest/api/latest/result/PPP-AO?expand=stages'

I meant to show that other requests does work.

Anyway... I restarted my computer and it now works, I have no idea how.
Thank you!


Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events