Find workspace level variables.
by hugo697 ยท 10/24/2023
1
type Bitbucket = {
2
username: string;
3
password: string;
4
};
5
/**
6
* List variables for a workspace
7
* Find workspace level variables.
8
*/
9
export async function main(auth: Bitbucket, workspace: string) {
10
const url = new URL(
11
`https://api.bitbucket.org/2.0/workspaces/${workspace}/pipelines-config/variables`
12
);
13
14
const response = await fetch(url, {
15
method: "GET",
16
headers: {
17
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
18
},
19
body: undefined,
20
});
21
if (!response.ok) {
22
const text = await response.text();
23
throw new Error(`${response.status} ${text}`);
24
}
25
return await response.json();
26
27