Regarding forge: pipelines not giving variables

Nuwan Udara August 20, 2024

I tried to get the variables of a triggered pipeline in the Dynamic pipeline, but cannot find a way to do it. How can I get the pipeline variable values from the forge app, the request or event does not contain it.

Also,

'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines/{pipeline_uuid}'

Is suppose to return the variables of a given pipeline, but I only get 

"has_variables": false

and do not return my variables.


const res = await api

.asApp()

.requestBitbucket(route`/2.0/repositories/${workspaceUuid}/${repoSlug}/pipelines/${pipelineId}`, {

headers: {

'Accept': 'application/json'

}

})

 

This is the pipeline I am triggering, Note that I am using the Custom pipeline

image: atlassian/default-image:3

pipelines:

default:

- step:

name: 'Deployment to Staging'

script:

- echo "Your deployment to staging script goes here..."

- step:

name: 'Deployment to Production'

script:

- set -e

- echo "Your deployment to production script goes here..."

custom:

testpipe:

- variables:

- name: Force

default: "no"

allowed-values:

- "no"

- "yes"

- name: env

- step:

script:

- cat test.txt

- echo $Force

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 4, 2024

Hi @Nuwan Udara,

Where are the variables defined?

If they are defined on the repository, you want to use the `/2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables` endpoint (see 
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-config-variables-get)

For variables defined on the workspace instead, this is the endpoint `/2.0/workspaces/{workspace}/pipelines-config/variables` (see https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-workspaces-workspace-pipelines-config-variables-get)

 

Hope this helps,
Caterina

Nuwan Udara September 7, 2024

Hi @Caterina Curti 

Sorry if my question was unclear. Let me rephrase the question.
I want to get the Provided variables in a pipeline.

testpipe:

- variables:

- name: Force

default: "no"

allowed-values:

- "no"

- "yes"

- name: env

For example value I passed for the env variable or the selected value for the Forced variable. These are called pipeline variables right.

 

My goal is to change the runner tags based on user inputs. Is it possible?

Like Caterina Curti likes this
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 9, 2024

Oh I see! My bad for not fully understanding the request here.

You are right that the variables are currently not available in either the request or the REST APIs.

I went ahead and created this ticket for tracking this suggestion:
https://jira.atlassian.com/browse/BCLOUD-23395


At this stage, there is no alternative that I can suggest @Nuwan Udara

Like # people like this
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events