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

Is it possible to access the variables used for a custom pipeline via BitBucket API?

Brenainn Moushall
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 25, 2022

I'm running custom pipelines that take variables, and I'd like to be able to retrieve the {key:  val} pairs for the variables when fetching a pipeline from the API.

I can see that there's endpoints for repository, workspace and environment variables, but I need the key-value pairs specified when the pipeline is launched.

I've looked through the pipeline response from

GET /2.0/repositories/{workspace}/{repo_slug}/pipelines/{pipeline_uuid}

and step response from

GET /2.0/repositories/{workspace}/{repo_slug}/pipelines/{pipeline_uuid}/steps/{step_uuid}

and they don't seem to be included. Pipeline response does have a 'has_variables' boolean, but I'm not sure if this refers to the custom pipeline variables or other types.

Just want to know if this is possible, as I can work around it otherwise.

Cheers!

2 answers

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2022

Hi @Brenainn Moushall,

I'm afraid that this is not possible with the pipeline or step endpoint.

The values of these variables are visible in the Pipelines log, in the "Build setup", which can be retrieved with the endpoint

GET /2.0/repositories/{workspace}/{repo_slug}/pipelines/{pipeline_uuid}/steps/{step_uuid}/log

You would then need to parse the log to get the value of each variable.

Kind regards,
Theodora

Brenainn Moushall
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 28, 2022

No problem, thanks for letting me know

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 29, 2022

You are very welcome, please feel free to reach out if you ever need anything else!

Kind regards,
Theodora

0 votes
Julien Bras
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 13, 2024

Hi,

We are in 2024, is-it still the only option to get access to the variables set during the pipeline launch via API?

Because the API documentation show us a nice `variables` prop in the `list pipelines` operation ;)

 

https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-get

 

{
"page": 102,
"values": [
{
"type": "<string>",
"uuid": "<string>",
"build_number": 33,
"creator": {
"type": "<string>"
},
"repository": {
"type": "<string>"
},
"target": {
"type": "<string>"
},
"trigger": {
"type": "<string>"
},
"state": {
"type": "<string>"
},
"variables": [
{
"type": "<string>"
}
],
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 14, 2024

Hi Julien,

The option mentioned in my answer above is the only one at the moment.

The "variables" property is not returned with the pipeline endpoint, I have reached out to my team internally to remove this from our docs in order to avoid confusion.

I also created a feature request for returning custom pipelines' variables and their values via API:

You can add your vote to it (by selecting the Vote for this issue link) to express your interest and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to be notified via email on updates.

Kind regards,
Theodora

Julien Bras
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 14, 2024

hi, thanks for the update and the documentation clarification! I will check the feature request creation to vote for it!

 

Thanks!

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events