Raw
1 import { Table, Note, CodeTabs, CodeTab } from "docs-ui"
2
3 export const metadata = {
4 title: `deployments Command - Medusa Cloud CLI Reference`,
5 }
6
7 # {metadata.title}
8
9 In this guide, you'll learn how to inspect Cloud deployments and their build logs using the CLI.
10
11 ## deployments list
12
13 List recent deployments for a project. By default, the command returns the 20 most recent deployments across all environments in the project, ordered by creation time (newest first).
14
15 <CodeTabs group="cli-auth">
16 <CodeTab label="With Flags" value="flags">
17
18 ```bash
19 mcloud deployments list --organization org_123 --project proj_123
20 ```
21
22 </CodeTab>
23 <CodeTab label="Using mcloud use" value="use">
24
25 ```bash
26 # Run once: mcloud use --organization org_123 --project proj_123
27
28 mcloud deployments list
29 ```
30
31 </CodeTab>
32 </CodeTabs>
33
34 ### Options
35
36 <Table>
37 <Table.Header>
38 <Table.Row>
39 <Table.HeaderCell>
40 Option
41 </Table.HeaderCell>
42 <Table.HeaderCell>
43 Description
44 </Table.HeaderCell>
45 <Table.HeaderCell>
46 Required
47 </Table.HeaderCell>
48 <Table.HeaderCell>
49 Default
50 </Table.HeaderCell>
51 </Table.Row>
52 </Table.Header>
53 <Table.Body>
54 <Table.Row>
55 <Table.Cell>
56
57 `-o <id>`, `--organization <id>`
58
59 </Table.Cell>
60 <Table.Cell>
61
62 The [ID of the organization](../organizations/page.mdx#find-organization-id) that the project belongs to.
63
64 </Table.Cell>
65 <Table.Cell>
66
67 Yes
68
69 </Table.Cell>
70 <Table.Cell>
71
72 Falls back to the organization in the [active context](../use/page.mdx), if set.
73
74 </Table.Cell>
75 </Table.Row>
76 <Table.Row>
77 <Table.Cell>
78
79 `-p <id-or-handle>`, `--project <id-or-handle>`
80
81 </Table.Cell>
82 <Table.Cell>
83
84 The [ID or handle of the project](../projects/page.mdx#find-project-ids-and-handles) to list deployments from.
85
86 </Table.Cell>
87 <Table.Cell>
88
89 Yes
90
91 </Table.Cell>
92 <Table.Cell>
93
94 Falls back to the project in the [active context](../use/page.mdx), if set.
95
96 </Table.Cell>
97 </Table.Row>
98 <Table.Row>
99 <Table.Cell>
100
101 `-e <handle>`, `--environment <handle>`
102
103 </Table.Cell>
104 <Table.Cell>
105
106 Filter deployments to a specific environment by [handle](../environments/page.mdx#find-environment-handles). If not provided, and not set in the [active context](../use/page.mdx#set-the-active-context), deployments from all environments in the project will be returned.
107
108 </Table.Cell>
109 <Table.Cell>
110
111 No
112
113 </Table.Cell>
114 <Table.Cell>
115
116 Falls back to the environment in the [active context](../use/page.mdx#set-the-active-context), if set.
117
118 </Table.Cell>
119 </Table.Row>
120 <Table.Row>
121 <Table.Cell>
122
123 `--environment-type <type>`
124
125 </Table.Cell>
126 <Table.Cell>
127
128 Filter deployments by environment type. One of `production`, `long-lived`, or `preview`. If you set the environment using its flag or in the active context, this filter is applied to the specified environment.
129
130 </Table.Cell>
131 <Table.Cell>
132
133 No
134
135 </Table.Cell>
136 <Table.Cell>
137
138 \-
139
140 </Table.Cell>
141 </Table.Row>
142 <Table.Row>
143 <Table.Cell>
144
145 `--commit <sha>`
146
147 </Table.Cell>
148 <Table.Cell>
149
150 Filter deployments by Git commit SHA. Accepts a full SHA or a prefix.
151
152 </Table.Cell>
153 <Table.Cell>
154
155 No
156
157 </Table.Cell>
158 <Table.Cell>
159
160 \-
161
162 </Table.Cell>
163 </Table.Row>
164 <Table.Row>
165 <Table.Cell>
166
167 `--limit <number>`
168
169 </Table.Cell>
170 <Table.Cell>
171
172 Maximum number of deployments to return. Minimum: `1`, maximum: `200`.
173
174 </Table.Cell>
175 <Table.Cell>
176
177 No
178
179 </Table.Cell>
180 <Table.Cell>
181
182 `20`
183
184 </Table.Cell>
185 </Table.Row>
186 <Table.Row>
187 <Table.Cell>
188
189 `--offset <number>`
190
191 </Table.Cell>
192 <Table.Cell>
193
194 The number of deployments to skip before retrieving the deployments. Useful for pagination.
195
196 </Table.Cell>
197 <Table.Cell>
198
199 No
200
201 </Table.Cell>
202 <Table.Cell>
203
204 `0`
205
206 </Table.Cell>
207 </Table.Row>
208 <Table.Row>
209 <Table.Cell>
210
211 `--json`
212
213 </Table.Cell>
214 <Table.Cell>
215
216 Print the result as JSON instead of formatted text.
217
218 </Table.Cell>
219 <Table.Cell>
220
221 No
222
223 </Table.Cell>
224 <Table.Cell>
225
226 `false`
227
228 </Table.Cell>
229 </Table.Row>
230 </Table.Body>
231 </Table>
232
233 ---
234
235 ## deployments get
236
237 Retrieve a single deployment by its ID. Returns the deployment's status, commit details, environment, and timestamps as a key-value list.
238
239 <Note>
240
241 This only retrieves the deployment's details. If you want to view its build logs, use [`mcloud deployments build-logs`](#deployments-build-logs) instead.
242
243 </Note>
244
245 <CodeTabs group="cli-auth">
246 <CodeTab label="With Flags" value="flags">
247
248 ```bash
249 mcloud deployments get <deployment> --organization org_123 --project proj_123
250 ```
251
252 </CodeTab>
253 <CodeTab label="Using mcloud use" value="use">
254
255 ```bash
256 # Run once: mcloud use --organization org_123 --project proj_123
257
258 mcloud deployments get <deployment>
259 ```
260
261 </CodeTab>
262 </CodeTabs>
263
264 ### Arguments
265
266 <Table>
267 <Table.Header>
268 <Table.Row>
269 <Table.HeaderCell>
270 Option
271 </Table.HeaderCell>
272 <Table.HeaderCell>
273 Description
274 </Table.HeaderCell>
275 <Table.HeaderCell>
276 Required
277 </Table.HeaderCell>
278 </Table.Row>
279 </Table.Header>
280 <Table.Body>
281 <Table.Row>
282 <Table.Cell>
283
284 `deployment`
285
286 </Table.Cell>
287 <Table.Cell>
288
289 The ID of the deployment to retrieve.
290
291 </Table.Cell>
292 <Table.Cell>
293
294 Yes
295
296 </Table.Cell>
297 </Table.Row>
298 </Table.Body>
299 </Table>
300
301 ### Options
302
303 <Table>
304 <Table.Header>
305 <Table.Row>
306 <Table.HeaderCell>
307 Option
308 </Table.HeaderCell>
309 <Table.HeaderCell>
310 Description
311 </Table.HeaderCell>
312 <Table.HeaderCell>
313 Required
314 </Table.HeaderCell>
315 <Table.HeaderCell>
316 Default
317 </Table.HeaderCell>
318 </Table.Row>
319 </Table.Header>
320 <Table.Body>
321 <Table.Row>
322 <Table.Cell>
323
324 `-o <id>`, `--organization <id>`
325
326 </Table.Cell>
327 <Table.Cell>
328
329 The [ID of the organization](../organizations/page.mdx#find-organization-id) that the project belongs to.
330
331 </Table.Cell>
332 <Table.Cell>
333
334 Yes
335
336 </Table.Cell>
337 <Table.Cell>
338
339 Falls back to the organization in the [active context](../use/page.mdx#set-the-active-context), if set.
340
341 </Table.Cell>
342 </Table.Row>
343 <Table.Row>
344 <Table.Cell>
345
346 `-p <id-or-handle>`, `--project <id-or-handle>`
347
348 </Table.Cell>
349 <Table.Cell>
350
351 The [ID or handle of the project](../projects/page.mdx#find-project-ids-and-handles) that the deployment belongs to.
352
353 </Table.Cell>
354 <Table.Cell>
355
356 Yes
357
358 </Table.Cell>
359 <Table.Cell>
360
361 Falls back to the project in the [active context](../use/page.mdx#set-the-active-context), if set.
362
363 </Table.Cell>
364 </Table.Row>
365 <Table.Row>
366 <Table.Cell>
367
368 `--json`
369
370 </Table.Cell>
371 <Table.Cell>
372
373 Print the result as JSON instead of formatted text.
374
375 </Table.Cell>
376 <Table.Cell>
377
378 No
379
380 </Table.Cell>
381 <Table.Cell>
382
383 `false`
384
385 </Table.Cell>
386 </Table.Row>
387 </Table.Body>
388 </Table>
389
390 ---
391
392 ## deployments build-logs
393
394 Fetch the build logs for a deployment. Use this to debug build failures or to inspect the build output for a specific deployment.
395
396 <Note title="Tip">
397
398 To fetch the runtime logs for a deployment after it is live, use [`mcloud logs --deployment <id>`](../logs/page.mdx#fetch-logs-for-a-specific-deployment) instead.
399
400 </Note>
401
402 <CodeTabs group="cli-auth">
403 <CodeTab label="With Flags" value="flags">
404
405 ```bash
406 mcloud deployments build-logs <deployment> --organization org_123 --project proj_123
407 ```
408
409 </CodeTab>
410 <CodeTab label="Using mcloud use" value="use">
411
412 ```bash
413 # Run once: mcloud use --organization org_123 --project proj_123
414
415 mcloud deployments build-logs <deployment>
416 ```
417
418 </CodeTab>
419 </CodeTabs>
420
421 ### Arguments
422
423 <Table>
424 <Table.Header>
425 <Table.Row>
426 <Table.HeaderCell>
427 Option
428 </Table.HeaderCell>
429 <Table.HeaderCell>
430 Description
431 </Table.HeaderCell>
432 <Table.HeaderCell>
433 Required
434 </Table.HeaderCell>
435 </Table.Row>
436 </Table.Header>
437 <Table.Body>
438 <Table.Row>
439 <Table.Cell>
440
441 `deployment`
442
443 </Table.Cell>
444 <Table.Cell>
445
446 The ID of the deployment to retrieve the build logs for.
447
448 </Table.Cell>
449 <Table.Cell>
450
451 Yes
452
453 </Table.Cell>
454 </Table.Row>
455 </Table.Body>
456 </Table>
457
458 ### Options
459
460 <Table>
461 <Table.Header>
462 <Table.Row>
463 <Table.HeaderCell>
464 Option
465 </Table.HeaderCell>
466 <Table.HeaderCell>
467 Description
468 </Table.HeaderCell>
469 <Table.HeaderCell>
470 Required
471 </Table.HeaderCell>
472 <Table.HeaderCell>
473 Default
474 </Table.HeaderCell>
475 </Table.Row>
476 </Table.Header>
477 <Table.Body>
478 <Table.Row>
479 <Table.Cell>
480
481 `-o <id>`, `--organization <id>`
482
483 </Table.Cell>
484 <Table.Cell>
485
486 The [ID of the organization](../organizations/page.mdx#find-organization-id) that the project belongs to.
487
488 </Table.Cell>
489 <Table.Cell>
490
491 Yes
492
493 </Table.Cell>
494 <Table.Cell>
495
496 Falls back to the organization in the [active context](../use/page.mdx#set-the-active-context), if set.
497
498 </Table.Cell>
499 </Table.Row>
500 <Table.Row>
501 <Table.Cell>
502
503 `-p <id-or-handle>`, `--project <id-or-handle>`
504
505 </Table.Cell>
506 <Table.Cell>
507
508 The [ID or handle of the project](../projects/page.mdx#find-project-ids-and-handles) that the deployment belongs to.
509
510 </Table.Cell>
511 <Table.Cell>
512
513 Yes
514
515 </Table.Cell>
516 <Table.Cell>
517
518 Falls back to the project in the [active context](../use/page.mdx#set-the-active-context), if set.
519
520 </Table.Cell>
521 </Table.Row>
522 <Table.Row>
523 <Table.Cell>
524
525 `--type <backend|storefront>`
526
527 </Table.Cell>
528 <Table.Cell>
529
530 Which build log stream to read.
531
532 </Table.Cell>
533 <Table.Cell>
534
535 No
536
537 </Table.Cell>
538 <Table.Cell>
539
540 `backend`
541
542 </Table.Cell>
543 </Table.Row>
544 <Table.Row>
545 <Table.Cell>
546
547 `--json`
548
549 </Table.Cell>
550 <Table.Cell>
551
552 Print the result as JSON instead of formatted text.
553
554 </Table.Cell>
555 <Table.Cell>
556
557 No
558
559 </Table.Cell>
560 <Table.Cell>
561
562 `false`
563
564 </Table.Cell>
565 </Table.Row>
566 </Table.Body>
567 </Table>
568
569 ---
570
571 ## Investigate a Failed Deployment
572
573 When a deployment fails, combine `deployments list`, `deployments get`, and `deployments build-logs` to find the deployment, inspect its status, and read the build output.
574
575 ### Check Build Logs for a Failed Deployment
576
577 If the build itself failed (status `build-failed`), use `deployments build-logs` to read the build output:
578
579 ```bash
580 # Assuming context is set with mcloud use. Otherwise, add the necessary flags to each command as shown in previous sections.
581
582 # Find the most recent build-failed deployment and store its ID in a variable
583 DEPLOYMENT_ID=$(
584 mcloud deployments list --json \
585 | jq -r '.[] | select(.backend_status == "build-failed") | .id' \
586 | head -n 1
587 )
588
589 # Get deployment details
590 mcloud deployments get "$DEPLOYMENT_ID"
591
592 # Fetch its backend build logs
593 mcloud deployments build-logs "$DEPLOYMENT_ID"
594
595 # Or fetch the storefront build logs
596 mcloud deployments build-logs "$DEPLOYMENT_ID" --type storefront
597 ```
598
599 ### Check Runtime Logs for a Failed Deployment
600
601 If the build succeeded but the rollout failed (status `deployment-failed`), the build logs won't show the cause. Use [`mcloud logs`](../logs/page.mdx) with `--deployment` to read the runtime logs for that specific deployment:
602
603 ```bash
604 # Assuming context is set with mcloud use. Otherwise, add the necessary flags to each command as shown in previous sections.
605
606 # Find the most recent deployment-failed deployment and store its ID in a variable
607 DEPLOYMENT_ID=$(
608 mcloud deployments list --json \
609 | jq -r '.[] | select(.backend_status == "deployment-failed") | .id' \
610 | head -n 1
611 )
612
613 # Get deployment details
614 mcloud deployments get "$DEPLOYMENT_ID"
615
616 # Fetch the runtime logs scoped to that deployment
617 mcloud logs --deployment "$DEPLOYMENT_ID" --limit 1000
618
619 # Or filter to error-level lines only
620 mcloud logs --deployment "$DEPLOYMENT_ID" --search error --limit 1000
621 ```
622
623 To redeploy after fixing the underlying issue, use [`mcloud environments redeploy`](../environments/page.mdx#environments-redeploy). To start a fresh build from the tracked branch, use [`mcloud environments trigger-build`](../environments/page.mdx#environments-trigger-build).
624
625 ---
626
627 ## Backend and Storefront Statuses
628
629 When retrieving the details of a deployment, you can see the backend and storefront statuses through the `backend_status` and `storefront_status` fields when using the `--json` flag.
630
631 Possible backend and storefront statuses are:
632
633 <Table>
634 <Table.Header>
635 <Table.Row>
636 <Table.HeaderCell>
637 Status
638 </Table.HeaderCell>
639 <Table.HeaderCell>
640 Description
641 </Table.HeaderCell>
642 </Table.Row>
643 </Table.Header>
644 <Table.Body>
645 <Table.Row>
646 <Table.Cell>
647
648 `created`
649
650 </Table.Cell>
651 <Table.Cell>
652
653 The deployment record exists but the build has not started yet.
654
655 </Table.Cell>
656 </Table.Row>
657 <Table.Row>
658 <Table.Cell>
659
660 `building`
661
662 </Table.Cell>
663 <Table.Cell>
664
665 The build is running. Use [`mcloud deployments build-logs`](#deployments-build-logs) to follow the output.
666
667 </Table.Cell>
668 </Table.Row>
669 <Table.Row>
670 <Table.Cell>
671
672 `built`
673
674 </Table.Cell>
675 <Table.Cell>
676
677 The build finished successfully but the deployment to the environment hasn't started yet.
678
679 </Table.Cell>
680 </Table.Row>
681 <Table.Row>
682 <Table.Cell>
683
684 `deploying`
685
686 </Table.Cell>
687 <Table.Cell>
688
689 The built artifact is being rolled out to the environment.
690
691 </Table.Cell>
692 </Table.Row>
693 <Table.Row>
694 <Table.Cell>
695
696 `deployed`
697
698 </Table.Cell>
699 <Table.Cell>
700
701 The deployment is live and serving traffic. The current active deployment for an environment is marked `(active)` in the formatted table. You can get the active deployment logs using [`mcloud logs --deployment <id>`](../logs/page.mdx#fetch-logs-for-a-specific-deployment).
702
703 </Table.Cell>
704 </Table.Row>
705 <Table.Row>
706 <Table.Cell>
707
708 `build-failed`
709
710 </Table.Cell>
711 <Table.Cell>
712
713 The build step failed before any code was deployed. Use [`mcloud deployments build-logs`](#deployments-build-logs) to find the build error.
714
715 </Table.Cell>
716 </Table.Row>
717 <Table.Row>
718 <Table.Cell>
719
720 `deployment-failed`
721
722 </Table.Cell>
723 <Table.Cell>
724
725 The build succeeded but the rollout to the environment failed. Use [`mcloud logs`](../logs/page.mdx) to fetch the logs for the affected deployment.
726
727 </Table.Cell>
728 </Table.Row>
729 <Table.Row>
730 <Table.Cell>
731
732 `timed-out`
733
734 </Table.Cell>
735 <Table.Cell>
736
737 The build or deployment exceeded the maximum allowed duration and was terminated. This status applies to backend deployments only.
738
739 </Table.Cell>
740 </Table.Row>
741 <Table.Row>
742 <Table.Cell>
743
744 `canceled`
745
746 </Table.Cell>
747 <Table.Cell>
748
749 The build or deployment was canceled, usually because a newer deployment superseded it.
750
751 </Table.Cell>
752 </Table.Row>
753 <Table.Row>
754 <Table.Cell>
755
756 `idle`
757
758 </Table.Cell>
759 <Table.Cell>
760
761 The deployment is no longer the active one for its environment. Idle deployments can be re-activated with [`mcloud environments redeploy`](../environments/page.mdx#environments-redeploy).
762
763 </Table.Cell>
764 </Table.Row>
765 </Table.Body>
766 </Table>