0

List last job commits

by
Published Oct 17, 2025

Returns list of the last 100 commits made on the repository linked to the job

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * List last job commits
4
 * Returns list of the last 100 commits made on the repository linked to the job
5
 */
6
export async function main(
7
	auth: RT.Qovery,
8
	jobId: string,
9
	startId?: string | undefined,
10
	gitCommitId?: string | undefined
11
) {
12
	const url = new URL(`https://api.qovery.com/job/${jobId}/commit`)
13
	for (const [k, v] of [
14
		['startId', startId],
15
		['gitCommitId', gitCommitId]
16
	]) {
17
		if (v !== undefined && v !== '') {
18
			url.searchParams.append(k, v)
19
		}
20
	}
21
	const response = await fetch(url, {
22
		method: 'GET',
23
		headers: {
24
			Authorization: 'Token ' + auth.apiKey
25
		},
26
		body: undefined
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.json()
33
}
34