0

Edit job

by
Published Oct 17, 2025

- To edit the job you must have the admin permission.

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Edit job
4
 * - To edit the job you must have the admin permission.
5

6
 */
7
export async function main(auth: RT.Qovery, jobId: string, body: Body) {
8
	const url = new URL(`https://api.qovery.com/job/${jobId}`)
9

10
	const response = await fetch(url, {
11
		method: 'PUT',
12
		headers: {
13
			'Content-Type': 'application/json',
14
			Authorization: 'Token ' + auth.apiKey
15
		},
16
		body: JSON.stringify(body)
17
	})
18
	if (!response.ok) {
19
		const text = await response.text()
20
		throw new Error(`${response.status} ${text}`)
21
	}
22
	return await response.json()
23
}
24

25
/* eslint-disable */
26
/**
27
 * This file was automatically generated by json-schema-to-typescript.
28
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
29
 * and run json-schema-to-typescript to regenerate this file.
30
 */
31

32
export type Body = {
33
	/**
34
	 * name is case insensitive
35
	 */
36
	name: string
37
	description?: string
38
	/**
39
	 * unit is millicores (m). 1000m = 1 cpu
40
	 */
41
	cpu?: number
42
	/**
43
	 * unit is MB. 1024 MB = 1GB
44
	 */
45
	memory?: number
46
	gpu?: number
47
	/**
48
	 * Maximum number of restart allowed before the job is considered as failed
49
	 * 0 means that no restart/crash of the job is allowed
50
	 *
51
	 */
52
	max_nb_restart?: number
53
	/**
54
	 * Maximum number of seconds allowed for the job to run before killing it and mark it as failed
55
	 *
56
	 */
57
	max_duration_seconds?: number
58
	/**
59
	 * Indicates if the 'environment preview option' is enabled for this container.
60
	 * If enabled, a preview environment will be automatically cloned when `/preview` endpoint is called.
61
	 * If not specified, it takes the value of the `auto_preview` property from the associated environment.
62
	 *
63
	 */
64
	auto_preview?: boolean
65
	/**
66
	 * Port where to run readiness and liveliness probes checks. The port will not be exposed externally
67
	 */
68
	port?: number
69
	source?: {
70
		image?: {
71
			/**
72
			 * The image name pattern differs according to chosen container registry provider:
73
			 * * `ECR`: `repository`
74
			 * * `SCALEWAY_CR`: `namespace/image`
75
			 * * `DOCKER_HUB`: `image` or `repository/image`
76
			 * * `PUBLIC_ECR`: `registry_alias/repository`
77
			 *
78
			 */
79
			image_name?: string
80
			/**
81
			 * tag of the image container
82
			 */
83
			tag?: string
84
			/**
85
			 * tag of the image container
86
			 */
87
			registry_id?: string
88
			[k: string]: unknown
89
		}
90
		docker?: {
91
			git_repository?: {
92
				/**
93
				 * application git repository URL
94
				 */
95
				url: string
96
				/**
97
				 * Name of the branch to use. This is optional
98
				 * If not specified, then the branch used is the `main` or `master` one
99
				 *
100
				 */
101
				branch?: string
102
				/**
103
				 * indicates the root path of the application.
104
				 */
105
				root_path?: string
106
				/**
107
				 * The git token id on Qovery side
108
				 */
109
				git_token_id?: string
110
				provider: 'BITBUCKET' | 'GITHUB' | 'GITLAB'
111
				[k: string]: unknown
112
			}
113
			/**
114
			 * The path of the associated Dockerfile. Only if you are using build_mode = DOCKER
115
			 */
116
			dockerfile_path?: string
117
			/**
118
			 * The content of your dockerfile if it is not stored inside your git repository
119
			 */
120
			dockerfile_raw?: string
121
			/**
122
			 * The target build stage in the Dockerfile to build
123
			 */
124
			docker_target_build_stage?: string
125
			[k: string]: unknown
126
		}
127
		[k: string]: unknown
128
	}
129
	healthchecks: {
130
		readiness_probe?: {
131
			type?: {
132
				tcp?: {
133
					port?: number
134
					host?: string
135
					[k: string]: unknown
136
				}
137
				http?: {
138
					path?: string
139
					scheme?: string
140
					port?: number
141
					[k: string]: unknown
142
				}
143
				exec?: {
144
					command?: string[]
145
					[k: string]: unknown
146
				}
147
				grpc?: {
148
					service?: string
149
					port?: number
150
					[k: string]: unknown
151
				}
152
				[k: string]: unknown
153
			}
154
			initial_delay_seconds?: number
155
			period_seconds?: number
156
			timeout_seconds?: number
157
			success_threshold?: number
158
			failure_threshold?: number
159
			[k: string]: unknown
160
		}
161
		liveness_probe?: {
162
			type?: {
163
				tcp?: {
164
					port?: number
165
					host?: string
166
					[k: string]: unknown
167
				}
168
				http?: {
169
					path?: string
170
					scheme?: string
171
					port?: number
172
					[k: string]: unknown
173
				}
174
				exec?: {
175
					command?: string[]
176
					[k: string]: unknown
177
				}
178
				grpc?: {
179
					service?: string
180
					port?: number
181
					[k: string]: unknown
182
				}
183
				[k: string]: unknown
184
			}
185
			initial_delay_seconds?: number
186
			period_seconds?: number
187
			timeout_seconds?: number
188
			success_threshold?: number
189
			failure_threshold?: number
190
			[k: string]: unknown
191
		}
192
		[k: string]: unknown
193
	}
194
	/**
195
	 * If you want to define a Cron job, only the `cronjob` property must be filled
196
	 * A Lifecycle job should contain at least one property `on_XXX` among the 3 properties: `on_start`, `on_stop`, `on_delete`
197
	 *
198
	 */
199
	schedule?: {
200
		on_start?: {
201
			arguments?: string[]
202
			/**
203
			 * optional entrypoint when launching container
204
			 */
205
			entrypoint?: string
206
			[k: string]: unknown
207
		}
208
		on_stop?: {
209
			arguments?: string[]
210
			/**
211
			 * optional entrypoint when launching container
212
			 */
213
			entrypoint?: string
214
			[k: string]: unknown
215
		}
216
		on_delete?: {
217
			arguments?: string[]
218
			/**
219
			 * optional entrypoint when launching container
220
			 */
221
			entrypoint?: string
222
			[k: string]: unknown
223
		}
224
		cronjob?: {
225
			arguments?: string[]
226
			/**
227
			 * optional entrypoint when launching container
228
			 */
229
			entrypoint?: string
230
			/**
231
			 * Specify a timezone identifier to run the schedule at. By default Etc/UTC
232
			 */
233
			timezone?: string
234
			/**
235
			 * Can only be set if the event is CRON.
236
			 * Represent the cron format for the job schedule without seconds.
237
			 * For example: `* * * * *` represent the cron to launch the job every minute.
238
			 * See https://crontab.guru/ to WISIWIG interface.
239
			 * Timezone is UTC
240
			 *
241
			 */
242
			scheduled_at: string
243
			[k: string]: unknown
244
		}
245
		lifecycle_type?: JobLifecycleTypeEnum
246
		[k: string]: unknown
247
	}
248
	/**
249
	 * Specify if the job will be automatically updated after receiving a new image tag or a new commit according to the source type.
250
	 * The new image tag shall be communicated via the "Auto Deploy job" endpoint https://api-doc.qovery.com/#tag/Jobs/operation/autoDeployJobEnvironments
251
	 *
252
	 */
253
	auto_deploy?: boolean
254
	annotations_groups?: {
255
		id: string
256
		[k: string]: unknown
257
	}[]
258
	labels_groups?: {
259
		id: string
260
		[k: string]: unknown
261
	}[]
262
	/**
263
	 * Icon URI representing the job.
264
	 */
265
	icon_uri?: string
266
	[k: string]: unknown
267
}
268
export type JobLifecycleTypeEnum = 'GENERIC' | 'TERRAFORM' | 'CLOUDFORMATION'
269