type Bitbucket = {
username: string;
password: string;
};
/**
* Create a build status for a commit
* Creates a new build status against the specified commit.
*/
export async function main(
auth: Bitbucket,
commit: 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`
);
const response = await fetch(url, {
method: "POST",
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 336 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Create a build status for a commit
* Creates a new build status against the specified commit.
*/
export async function main(
auth: Bitbucket,
commit: 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`
);
const response = await fetch(url, {
method: "POST",
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 415 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Create a build status for a commit
* Creates a new build status against the specified commit.
*/
export async function main(
auth: Bitbucket,
commit: 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`
);
const response = await fetch(url, {
method: "POST",
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 464 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Create a build status for a commit
* Creates a new build status against the specified commit.
*/
export async function main(
auth: Bitbucket,
commit: 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`
);
const response = await fetch(url, {
method: "POST",
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 469 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Create a build status for a commit
* Creates a new build status against the specified commit.
If the specified key already exists, the existing status object will
be overwritten.
Example:
```
curl https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/commit/e10dae226959c2194f2b07b077c07762d93821cf/statuses/build/ -X POST -u jdoe -H 'Content-Type: application/json' -d '{
"key": "MY-BUILD",
"state": "SUCCESSFUL",
"description": "42 tests passed",
"url": "https://www.example.org/my-build-result"
}'
```
When creating a new commit status, you can use a URI template for the URL.
Templates are URLs that contain variable names that Bitbucket will
evaluate at runtime whenever the URL is displayed anywhere similar to
parameter substitution in
[Bitbucket Connect](https://developer.atlassian.com/bitbucket/concepts/context-parameters.html).
For example, one could use `https://foo.com/builds/{repository.full_name}`
which Bitbucket will turn into `https://foo.com/builds/foo/bar` at render time.
The context variables available are `repository` and `commit`.
*/
export async function main(
auth: Bitbucket,
commit: 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`
);
const response = await fetch(url, {
method: "POST",
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 470 days ago