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
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
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.