index.md 12,2 КБ
Newer Older
James Ramsay's avatar
James Ramsay включено в состав коммита
1
2
# Web IDE

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
3
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/4539) in [GitLab Ultimate][ee] 10.4.
Stan Hu's avatar
Stan Hu включено в состав коммита
4
> [Brought to GitLab Core](https://gitlab.com/gitlab-org/gitlab-ce/issues/44157) in 10.7.
James Ramsay's avatar
James Ramsay включено в состав коммита
5

Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
6
7
The Web IDE editor makes it faster and easier to contribute changes to your
projects by providing an advanced editor with commit staging.
James Ramsay's avatar
James Ramsay включено в состав коммита
8
9
10

## Open the Web IDE

Philipp C. H's avatar
Philipp C. H включено в состав коммита
11
You can open the Web IDE when viewing a file, from the repository file list,
James Ramsay's avatar
James Ramsay включено в состав коммита
12
and from merge requests.
James Ramsay's avatar
James Ramsay включено в состав коммита
13
14
15

![Open Web IDE](img/open_web_ide.png)

James Ramsay's avatar
James Ramsay включено в состав коммита
16
## File finder
James Ramsay's avatar
James Ramsay включено в состав коммита
17

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
18
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18323) in [GitLab Core][ce] 10.8.
James Ramsay's avatar
James Ramsay включено в состав коммита
19
20
21
22
23
24

The file finder allows you to quickly open files in the current branch by
searching. The file finder is launched using the keyboard shortcut `Command-p`,
`Control-p`, or `t` (when editor is not in focus). Type the filename or
file path fragments to start seeing results.

Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
25
## Syntax highlighting
Marc Schwede's avatar
Marc Schwede включено в состав коммита
26

Evan Read's avatar
Evan Read включено в состав коммита
27
As expected from an IDE, syntax highlighting for many languages within
Marc Schwede's avatar
Marc Schwede включено в состав коммита
28
29
30
31
the Web IDE will make your direct editing even easier.

The Web IDE currently provides:

Evan Read's avatar
Evan Read включено в состав коммита
32
33
34
35
36
37
- Basic syntax colorization for a variety of programming, scripting and markup
  languages such as XML, PHP, C#, C++, Markdown, Java, VB, Batch, Python, Ruby
  and Objective-C.
- IntelliSense and validation support (displaying errors and warnings, providing
  smart completions, formatting, and outlining) for some languages. For example:
TypeScript, JavaScript, CSS, LESS, SCSS, JSON and HTML.
Marc Schwede's avatar
Marc Schwede включено в состав коммита
38

Evan Read's avatar
Evan Read включено в состав коммита
39
40
41
Because the Web IDE is based on the [Monaco Editor](https://microsoft.github.io/monaco-editor/),
you can find a more complete list of supported languages in the
[Monaco languages](https://github.com/Microsoft/monaco-languages) repository.
Marc Schwede's avatar
Marc Schwede включено в состав коммита
42
43
44
45

NOTE: **Note:**
Single file editing is based on the [Ace Editor](https://ace.c9.io).

James Ramsay's avatar
James Ramsay включено в состав коммита
46
47
## Stage and commit changes

Philipp C. H's avatar
Philipp C. H включено в состав коммита
48
After making your changes, click the **Commit** button in the bottom left to
James Ramsay's avatar
James Ramsay включено в состав коммита
49
review the list of changed files. Click on each file to review the changes and
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
50
click the tick icon to stage the file.
James Ramsay's avatar
James Ramsay включено в состав коммита
51
52

Once you have staged some changes, you can add a commit message and commit the
nyonyoron's avatar
nyonyoron включено в состав коммита
53
staged changes. Unstaged changes will not be committed.
James Ramsay's avatar
James Ramsay включено в состав коммита
54
55
56

![Commit changes](img/commit_changes.png)

James Ramsay's avatar
James Ramsay включено в состав коммита
57
## Reviewing changes
James Ramsay's avatar
James Ramsay включено в состав коммита
58
59
60
61
62
63
64
65

Before you commit your changes, you can compare them with the previous commit
by switching to the review mode or selecting the file from the staged files
list.

An additional review mode is available when you open a merge request, which
shows you a preview of the merge request diff if you commit your changes.

James Ramsay's avatar
James Ramsay включено в состав коммита
66
67
## View CI job logs

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
68
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19279) in [GitLab Core][ce] 11.0.
James Ramsay's avatar
James Ramsay включено в состав коммита
69

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
70
71
You can use the Web IDE to quickly fix failing tests by opening
the branch or merge request in the Web IDE and opening the logs of the failed
Philipp C. H's avatar
Philipp C. H включено в состав коммита
72
73
74
job. You can access the status of all jobs for the most recent pipeline and job
traces for the current commit by clicking the **Pipelines** button in the top
right.
James Ramsay's avatar
James Ramsay включено в состав коммита
75
76
77
78
79
80

The pipeline status is also shown at all times in the status bar in the bottom
left.

## Switching merge requests

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
81
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19318) in [GitLab Core][ce] 11.0.
James Ramsay's avatar
James Ramsay включено в состав коммита
82

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
83
84
To switch between your authored and assigned merge requests, click the
dropdown in the top of the sidebar to open a list of merge requests. You will
Philipp C. H's avatar
Philipp C. H включено в состав коммита
85
86
need to commit or discard all your changes before switching to a different merge
request.
James Ramsay's avatar
James Ramsay включено в состав коммита
87

Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
88
89
## Switching branches

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
90
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20850) in [GitLab Core][ce] 11.2.
Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
91

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
92
93
94
To switch between branches of the current project repository, click the dropdown
in the top of the sidebar to open a list of branches.
You will need to commit or discard all your changes before switching to a
Philipp C. H's avatar
Philipp C. H включено в состав коммита
95
different branch.
Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
96

James Ramsay's avatar
James Ramsay включено в состав коммита
97
## Client Side Evaluation
Phil Hughes's avatar
Phil Hughes включено в состав коммита
98

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
99
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19764) in [GitLab Core][ce] 11.2.
Phil Hughes's avatar
Phil Hughes включено в состав коммита
100

Philipp C. H's avatar
Philipp C. H включено в состав коммита
101
You can use the Web IDE to preview JavaScript projects right in the browser.
James Ramsay's avatar
James Ramsay включено в состав коммита
102
This feature uses CodeSandbox to compile and bundle the JavaScript used to
James Ramsay's avatar
James Ramsay включено в состав коммита
103
preview the web application.
Phil Hughes's avatar
Phil Hughes включено в состав коммита
104

James Ramsay's avatar
James Ramsay включено в состав коммита
105
![Web IDE Client Side Evaluation](img/clientside_evaluation.png)
Phil Hughes's avatar
Phil Hughes включено в состав коммита
106

Philipp C. H's avatar
Philipp C. H включено в состав коммита
107
Additionally, for public projects an **Open in CodeSandbox** button is available
James Ramsay's avatar
James Ramsay включено в состав коммита
108
109
110
to transfer the contents of the project into a public CodeSandbox project to
quickly share your project with others.

James Ramsay's avatar
James Ramsay включено в состав коммита
111
### Enabling Client Side Evaluation
Phil Hughes's avatar
Phil Hughes включено в состав коммита
112

James Ramsay's avatar
James Ramsay включено в состав коммита
113
114
115
The Client Side Evaluation feature needs to be enabled in the GitLab instances
admin settings. Client Side Evaluation is enabled for all projects on
GitLab.com
Phil Hughes's avatar
Phil Hughes включено в состав коммита
116

James Ramsay's avatar
James Ramsay включено в состав коммита
117
![Admin Client Side Evaluation setting](img/admin_clientside_evaluation.png)
Phil Hughes's avatar
Phil Hughes включено в состав коммита
118

Philipp C. H's avatar
Philipp C. H включено в состав коммита
119
Once you have done that, you can preview projects with a `package.json` file and
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
120
a `main` entry point inside the Web IDE. An example `package.json` is shown
Philipp C. H's avatar
Philipp C. H включено в состав коммита
121
below.
Phil Hughes's avatar
Phil Hughes включено в состав коммита
122
123
124
125
126
127
128
129
130
131

```json
{
  "main": "index.js",
  "dependencies": {
    "vue": "latest"
  }
}
```

Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
132
## Interactive Web Terminals for the Web IDE **(ULTIMATE ONLY)**
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
133
134
135
136
137

> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/5426) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 11.6.

CAUTION: **Warning:**
Interactive Web Terminals for the Web IDE is currently in **Beta**.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
138
139
Shared Runners [do not yet support Interactive Web Terminals](https://gitlab.com/gitlab-org/gitlab-ce/issues/52611),
so you would need to use your own private Runner(s) to make use of this feature.
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
140

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
141
142
143
[Interactive Web Terminals](../../../ci/interactive_web_terminal/index.md)
give the project [Maintainers](../../permissions.md#project-members-permissions)
user access to a terminal to interact with the Runner directly from
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
144
145
146
147
148
149
150
GitLab, including through the Web IDE.

### Runner configuration

Some things need to be configured in the runner for the interactive web terminal
to work:

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
151
- The Runner needs to have
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
152
153
  [`[session_server]` configured properly](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-session_server-section).
- If you are using a reverse proxy with your GitLab instance, web terminals need to be
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
154
  [enabled](../../../administration/integration/terminal.md#enabling-and-disabling-terminal-support). **(ULTIMATE ONLY)**
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173

If you have the terminal open and the job has finished with its tasks, the
terminal will block the job from finishing for the duration configured in
[`[session_server].terminal_max_retention_time`](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-session_server-section)
until you close the terminal window.

NOTE: **Note:** Not all executors are
[supported](https://docs.gitlab.com/runner/executors/#compatibility-chart)

### Web IDE configuration file

In order to enable the Web IDE terminals you need to create the file
`.gitlab/.gitlab-webide.yml` inside the repository's root. This
file is fairly similar to the [CI configuration file](../../../ci/yaml/README.md)
syntax but with some restrictions:

- No global blocks can be defined (ie: `before_script` or `after_script`)
- Only one job named `terminal` can be added to this file.
- Only the keywords `image`, `services`, `tags`, `before_script`, `script`, and
Evan Read's avatar
Evan Read включено в состав коммита
174
  `variables` are allowed to be used to configure the job.
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
175
- To connect to the interactive terminal, the `terminal` job must be still alive
Evan Read's avatar
Evan Read включено в состав коммита
176
177
178
179
180
  and running, otherwise the terminal won't be able to connect to the job's session.
  By default the `script` keyword has the value `sleep 60` to prevent
  the job from ending and giving the Web IDE enough time to connect. This means
  that, if you override the default `script` value, you'll have to add a command
  which would keep the job running, like `sleep`.
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

In the code below there is an example of this configuration file:

```yaml
terminal:
  before_script:
    - apt-get update
  script: sleep 60
  variables:
    RAILS_ENV: "test"
    NODE_ENV: "test"
```

Once the terminal has started, the console will be displayed and we could access
the project repository files.

Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
197
**Important**. The terminal job is branch dependent. This means that the
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
198
199
200
201
202
configuration file used to trigger and configure the terminal will be the one in
the selected branch of the Web IDE.

If there is no configuration file in a branch, an error message will be shown.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
203
### Running interactive terminals in the Web IDE
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
204
205
206
207
208
209
210

If Interactive Terminals are available for the current user, the **Terminal** button
will be visible in the right sidebar of the Web IDE. Click this button to open
or close the terminal tab.

Once open, the tab will show the **Start Web Terminal** button. This button may
be disabled if the environment is not configured correctly. If so, a status
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
211
message will describe the issue. Here are some reasons why **Start Web Terminal**
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
may be disabled:

- `.gitlab/.gitlab-webide.yml` does not exist or is set up incorrectly.
- No active private runners are available for the project.

If active, clicking the **Start Web Terminal** button will load the terminal view
and start connecting to the runner's terminal. At any time, the **Terminal** tab
can be closed and reopened and the state of the terminal will not be affected.

When the terminal is started and is successfully connected to the runner, then the
runner's shell prompt will appear in the terminal. From here, you can enter
commands that will be executed within the runner's environment. This is similar
to running commands in a local terminal or through SSH.

While the terminal is running, it can be stopped by clicking **Stop Terminal**.
This will disconnect the terminal and stop the runner's terminal job. From here,
click **Restart Terminal** to start a new terminal session.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
230
### File syncing to web terminal
Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
231
232
233

> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/5276) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.0.

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
234
File changes in the Web IDE can be synced to a running web terminal.
Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
235
236
237
238
239
240
This enables users to test their code changes in a preconfigured terminal
environment.

NOTE: **Note:**
Only file changes in the Web IDE are synced to the terminal.
Changes made in the terminal are **not** synced to the Web IDE.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
241
This feature is only available for Kubernetes Runners.
Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
242

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
243
244
To enable file syncing to the web terminal, the `.gitlab/.gitlab-webide.yml`
file needs to have a `webide-file-sync` service configured. Here is an example
Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
245
246
247
248
249
configuration for a Node JS project which uses this service:

```yaml
terminal:
  # This can be any image that has the necessary runtime environment for your project.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
250
  image:
Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
251
252
253
254
255
256
257
258
259
260
261
    name: node:10-alpine
  services:
    - name: registry.gitlab.com/gitlab-org/webide-file-sync:latest
      alias: webide-file-sync
      entrypoint: ["/bin/sh"]
      command: ["-c", "sleep 5 && ./webide-file-sync -project-dir $CI_PROJECT_DIR"]
      ports:
        # The `webide-file-sync` executable defaults to port 3000.
        - number: 3000
```

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
- The `webide-file-sync` executable must start **after** the project
  directory is available. This is why we need to add `sleep 5` to the `command`.
  See [this issue](https://gitlab.com/gitlab-org/webide-file-sync/issues/7) for
  more info.
- `$CI_PROJECT_DIR` is a
  [predefined environment variable](../../../ci/variables/predefined_variables.md)
  for GitLab Runners. This is where your project's repository will be.

Once you have configured the web terminal for file syncing, then when the web
terminal is started, a **Terminal** status will be visible in the status bar.

![Web IDE Client Side Evaluation](img/terminal_status.png)

Changes made to your files via the Web IDE will sync to the running terminal
when:

- <kbd>Ctrl</kbd> + <kbd>S</kbd> (or <kbd>Cmd</kbd> + <kbd>S</kbd> on Mac)
  is pressed while editing a file.
- Anything outside the file editor is clicked after editing a file.
- A file or folder is created, deleted, or renamed.
Paul Slaughter's avatar
Paul Slaughter включено в состав коммита
282

Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
283
284
### Limitations

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
285
Interactive Terminals is in a beta phase and will continue to be improved upon in upcoming
Marcel Amirault's avatar
Marcel Amirault включено в состав коммита
286
287
288
289
290
291
292
293
294
295
296
297
releases. In the meantime, please note that the user is limited to having only one
active terminal at a time.

### Troubleshooting

- If the terminal's text is gray and unresponsive, then the terminal has stopped
  and it can no longer be used. A stopped terminal can be restarted by clicking
  **Restart Terminal**.
- If the terminal displays **Connection Failure**, then the terminal could not
  connect to the runner. Please try to stop and restart the terminal. If the
  problem persists, double check your runner configuration.

James Ramsay's avatar
James Ramsay включено в состав коммита
298
[ce]: https://about.gitlab.com/pricing/
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
299
[ee]: https://about.gitlab.com/pricing/