type Bitbucket = {
username: string;
password: string;
};
/**
* Update a build status for a commit
* Used to update the current status of a build status object on the
specific commit.
This operation can also be used to change other properties of the
build status:
* `state`
* `name`
* `description`
* `url`
* `refname`
The `key` cannot be changed.
*/
export async function main(
auth: Bitbucket,
commit: string,
key: string,
repo_slug: string,
workspace: string,
body: { type: string; [k: string]: unknown } & {
links?: {
self?: { href?: string; name?: string };
commit?: { href?: string; name?: string };
};
uuid?: string;
key?: string;
refname?: string;
url?: string;
state?: "FAILED" | "INPROGRESS" | "STOPPED" | "SUCCESSFUL";
name?: string;
description?: string;
created_on?: string;
updated_on?: string;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
);
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.json();
}
Submitted by hugo697 75 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update a build status for a commit
* Used to update the current status of a build status object on the
specific commit.
This operation can also be used to change other properties of the
build status:
* `state`
* `name`
* `description`
* `url`
* `refname`
The `key` cannot be changed.
*/
export async function main(
auth: Bitbucket,
commit: string,
key: string,
repo_slug: string,
workspace: string,
body: { type: string; [k: string]: unknown } & {
links?: {
self?: { href?: string; name?: string };
commit?: { href?: string; name?: string };
};
uuid?: string;
key?: string;
refname?: string;
url?: string;
state?: "STOPPED" | "FAILED" | "INPROGRESS" | "SUCCESSFUL";
name?: string;
description?: string;
created_on?: string;
updated_on?: string;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
);
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.json();
}
Submitted by hugo697 154 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update a build status for a commit
* Used to update the current status of a build status object on the
specific commit.
This operation can also be used to change other properties of the
build status:
* `state`
* `name`
* `description`
* `url`
* `refname`
The `key` cannot be changed.
*/
export async function main(
auth: Bitbucket,
commit: string,
key: string,
repo_slug: string,
workspace: string,
body: { type: string; [k: string]: unknown } & {
links?: {
self?: { href?: string; name?: string };
commit?: { href?: string; name?: string };
};
uuid?: string;
key?: string;
refname?: string;
url?: string;
state?: "INPROGRESS" | "FAILED" | "SUCCESSFUL" | "STOPPED";
name?: string;
description?: string;
created_on?: string;
updated_on?: string;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
);
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.json();
}
Submitted by hugo697 203 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update a build status for a commit
* Used to update the current status of a build status object on the
specific commit.
This operation can also be used to change other properties of the
build status:
* `state`
* `name`
* `description`
* `url`
* `refname`
The `key` cannot be changed.
*/
export async function main(
auth: Bitbucket,
commit: string,
key: string,
repo_slug: string,
workspace: string,
body: { type: string; [k: string]: unknown } & {
links?: {
self?: { href?: string; name?: string };
commit?: { href?: string; name?: string };
};
uuid?: string;
key?: string;
refname?: string;
url?: string;
state?: "STOPPED" | "INPROGRESS" | "SUCCESSFUL" | "FAILED";
name?: string;
description?: string;
created_on?: string;
updated_on?: string;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commit/${commit}/statuses/build/${key}`
);
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.json();
}
Submitted by hugo697 209 days ago