type Bitbucket = {
username: string;
password: string;
};
/**
* Update a commit application property
* Update an application property value stored against a commit.
*/
export async function main(
auth: Bitbucket,
workspace: string,
repo_slug: string,
commit: string,
app_key: string,
property_name: string,
body: { _attributes?: ("public" | "read_only")[]; [k: string]: unknown }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/properties/${app_key}/${property_name}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 329 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update a commit application property
* Update an [application property](/cloud/bitbucket/application-properties/) value stored against a commit.
*/
export async function main(
auth: Bitbucket,
workspace: string,
repo_slug: string,
commit: string,
app_key: string,
property_name: string,
body: { _attributes?: ("public" | "read_only")[]; [k: string]: unknown }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/properties/${app_key}/${property_name}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 384 days ago