File: cicd.md

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (100 lines) | stat: -rw-r--r-- 4,389 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
stage: Create
group: Editor Extensions
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
description: "Use the GitLab Workflow extension for VS Code to handle common GitLab tasks directly in VS Code."
---

# CI/CD pipelines in the VS Code extension

If your GitLab project uses CI/CD pipelines, you can start, watch, and debug CI/CD pipelines from the
GitLab Workflow extension for VS Code. When you work locally on a Git branch, the bottom status bar
shows the status of its most recent pipeline, or shows **No pipeline** if a pipeline hasn't run yet:

![The bottom status bar, showing the most recent pipeline has failed.](../img/status_bar_pipeline_v17_6.png)

Possible statuses include:

- **Pipeline canceled**
- **Pipeline failed**
- **Pipeline passed**
- **Pipeline pending**
- **Pipeline running**
- **Pipeline skipped**

## View pipeline information

Use this extension to start, monitor, and debug CI/CD pipelines in GitLab.

Prerequisites:

- Your project uses CI/CD pipelines.
- A merge request exists for your current Git branch.
- The most recent commit on your current Git branch has a CI/CD pipeline.

To view pipeline information:

1. In VS Code, on the bottom status bar, select the pipeline status to display actions in the Command Palette.
1. In the Command Palette, select your desired action:

   - **Create New Pipeline From Current Branch**: Start a new pipeline.
   - **Cancel Last Pipeline**
   - **Download Artifacts from Latest Pipeline**: Download the pipeline artifact in ZIP or JSON format.
   - **Retry Last Pipeline**
   - **View Latest Pipeline on GitLab**: Open the pipeline's page in a browser tab.

## Show pipeline alerts

This extension can display an alert in VS Code when a pipeline for your current branch completes:

![Alert showing a pipeline failure](../img/pipeline_alert_v17_6.png)

To show alerts for your current Git branch:

1. In VS Code, on the top menu, select **Code > Settings > Settings**.
1. Depending on your configuration, select either **User** or **Workplace** settings.
1. In the main tab, select **Extensions > GitLab Workflow** to view this extension's settings.
1. Under **Show Pipeline Update Notifications**, select the **Show notification in VS Code when the pipeline status changes** checkbox.

## View CI/CD job output

To view the output for a CI/CD job for your current branch:

1. On the left vertical menu bar, select **GitLab Workflow** (**{tanuki}**) to display the extension sidebar.
1. On the sidebar, expand **For current branch** to show its most recent pipeline.
1. Select your desired job to open it in a new VS Code tab:

   ![A pipeline containing CI/CD jobs that are passing, allowed to fail, and failing.](../img/view_job_output_v17_6.png)

### Test GitLab CI/CD configuration

Use the `GitLab: Validate GitLab CI Config` command to test your project's GitLab CI/CD configuration locally.

1. In VS Code, open your `.gitlab-ci.yml` file, and ensure the file's tab is in focus.
1. Open the Command Palette:
   - For macOS, press <kbd>Command</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>.
   - For Windows or Linux, press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>.
1. In the Command Palette, search for `GitLab: Validate GitLab CI Config` and press <kbd>Enter</kbd>.

The extension shows an alert if it detects a problem with your configuration.

### Show merged GitLab CI/CD configuration

Use this command to see a preview of your merged CI/CD configuration file, with all includes and references resolved.

1. In VS Code, open your `.gitlab-ci.yml` file, and ensure the file's tab is in focus.
1. On the top right, select **Show Merged GitLab CI/CD Configuration**:

   ![The VS Code application, showing the icon for viewing merged results.](../img/show_merged_configuration_v17_6.png)

VS Code opens a new tab (`.gitlab-ci (Merged).yml`) with full information.

### CI/CD variable autocompletion

Quickly find the CI/CD variable you are looking for with the CI/CD variable autocompletion:

1. In VS Code, open your `.gitlab-ci.yml` file, and ensure the file's tab is in focus.
1. Begin entering the name of a variable to display auto-complete options.
1. Select an option to use it:

   ![Autocomplete options shown for a string](../img/ci_variable_autocomplete_v16_6.png)