This documentation is for a release that is no longer maintained
See documentation for the latest supported version.第 1 章 Dev Spaces 入门
如果您的机构已在运行 OpenShift Dev Spaces 实例,您可以作为新用户启动,方法是了解如何启动新的工作区,管理工作区,并从工作区向 Git 服务器验证自己到 Git 服务器:
1.1. 从 Git 存储库 URL 启动工作区 复制链接链接已复制到粘贴板!
使用 OpenShift Dev Spaces,您可以使用浏览器中的 URL 来启动一个包含 Git 存储库克隆的新工作区。这样,您可以克隆托管在 GitHub、GitLab、Bitbucket 或 Microsoft Azure DevOps 服务器实例上的 Git 存储库。
您还可以使用 OpenShift Dev Spaces 仪表板的 Create Workspace 页面中的 Git Repository URL 字段来输入 Git 存储库的 URL 来启动新的工作区。
- 如果使用 SSH URL 启动新的工作区,您必须传播 SSH 密钥。如需更多信息,请参阅配置 DevWorkspace 为 Git 操作使用 SSH 密钥。
-
如果 SSH URL 指向私有存储库,您必须应用访问令牌来获取
devfile.yaml
内容。您可以通过接受 SCM 身份验证页面或按照 个人访问令牌 流程进行此操作。
配置个人访问令牌以访问私有存储库。请参阅 第 6.1.2 节 “使用 Git-provider 访问令牌”。
先决条件
- 您的机构有一个 OpenShift Dev Spaces 实例运行。
-
您知道机构的 OpenShift Dev Spaces 实例的 FQDN URL:
https:// <openshift_dev_spaces_fqdn
>。 - 可选:您配置了 Git 服务器的身份验证。
您的 Git 存储库维护器将
devfile.yaml
或.devfile.yaml
文件保留在 Git 存储库的根目录中。(有关其他文件名和文件路径,请参阅 第 1.1.1 节 “用于启动新的工作区的 URL 的可选参数”。)提示您还可以通过提供不包含 devfile 的 Git 存储库的 URL 来启动新的工作区。这样做会产生一个使用通用基础镜像以及 Microsoft Visual Studio Code 的工作区 - Open Source 作为工作区 IDE。
流程
使用 Git 存储库克隆来启动一个新的工作区:
- 可选:访问 OpenShift Dev Spaces 仪表板页面,以向您的机构的 OpenShift Dev Spaces 实例进行身份验证。
访问 URL,以使用基本语法启动新的工作区:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 提示您可以使用可选参数扩展此 URL:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?<optional_parameters>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?<optional_parameters>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow 提示您可以使用 Git+SSH URL 来启动新的工作区。请参阅配置 DevWorkspace 为 Git 操作使用 SSH 密钥
例 1.1. 用于启动新工作区的 URL
-
https://<openshift_dev_spaces_fqdn>#https://github.com/che-samples/cpp-hello-world
-
https://<openshift_dev_spaces_fqdn>#git@github.com:che-samples/cpp-hello-world.git
例 1.2. 使用 GitHub 实例存储库克隆来启动新工作区的 URL 语法
-
https://<openshift_dev_spaces_fqdn> #https:/// <user_or_org> / <repository
> 启动一个带有默认分支克隆的新工作区。 -
https:// <openshift_dev_spaces_fqdn> #https:///<user_or_org> / <repository> /tree/ & lt;branch_name
> 启动一个带有指定分支克隆的新工作区。 -
https://<openshift_dev_spaces_fqdn> #https:/// <user_or_org> / <repository> /pull/ & lt;pull_request_id
> 启动带有拉取请求分支的新工作区。 -
https:// <openshift_dev_spaces_fqdn>#git@:<user_or_org> / <repository > .git
从 Git+SSH URL 启动一个新的工作区。
例 1.3. 使用 GitLab 实例存储库克隆来启动新工作区的 URL 语法
-
https://<openshift_dev_spaces_fqdn> #https:/// <user_or_org> / <repository
> 启动一个带有默认分支克隆的新工作区。 -
https:// <openshift_dev_spaces_fqdn> #https:///<user_or_org> / <repository> /-/tree/& lt;branch_name
> 启动带有指定分支克隆的新工作区。 -
https:// <openshift_dev_spaces_fqdn>#git@:<user_or_org> / <repository > .git
从 Git+SSH URL 启动一个新的工作区。
例 1.4. 使用 BitBucket 服务器存储库克隆来启动新工作区的 URL 语法
-
https:// <openshift_dev_spaces_fqdn> #https://<bb_host> /scm/ <project-key> / <repository > .git
启动一个带有默认分支克隆的新工作区。 -
https:// <openshift_dev_spaces_fqdn>#https:// <bb_host> /users/<user_slug> /repos/ <repository
> /repos/ has a new workspace of a clone of the default branch, if an repository was created in the user profile. -
https:// <openshift_dev_spaces_fqdn> #https://<bb_host> /users/ <user-slug> /repos/ <repository> /browse?at=refs%2Fheads%2F<branch-name
> 启动带有指定分支的克隆的新工作区。 -
https:// <openshift_dev_spaces_fqdn>#git@ <bb_host>: <user_slug> / <repository > .git
从 Git+SSH URL 启动一个新的工作区。
例 1.5. 使用 Microsoft Azure DevOps Git 存储库的克隆来启动新工作区的 URL 语法
-
https:// <openshift_dev_spaces_fqdn> #https://<organization> @dev.azure.com/<organization> / <project> /_git/ <repository
> 启动一个带有默认分支克隆的新工作区。 -
https:// <openshift_dev_spaces_fqdn>#https:// <organization> @dev.azure.com/<organization> / <project> /_git/ <repository > ?version=GB <branch
> 启动带有特定分支的克隆的新工作区。 -
https:// <openshift_dev_spaces_fqdn>#git@ssh.dev.azure.com:v3/ <organization> /<project> / <repository
> 从 Git+SSH URL 中启动新的工作区。
在输入 URL 以在浏览器标签页中启动新的工作区后,会显示工作区启动页面。
当新的工作区就绪后,工作区 IDE 会在浏览器选项卡中加载。
新工作区的文件系统中会出现 Git 存储库的克隆。
工作区具有唯一的 URL:
https:// <openshift_dev_spaces_fqdn> / <user_name> / <unique_url>
。-
其他资源
1.1.1. 用于启动新的工作区的 URL 的可选参数 复制链接链接已复制到粘贴板!
当您启动新的工作区时,OpenShift Dev Spaces 根据 devfile 中的说明配置工作区。当使用 URL 启动新的工作区时,您可以将可选参数附加到进一步配置工作区的 URL 中。您可以使用这些参数来指定工作区 IDE,启动重复的工作区,并指定 devfile 文件名或路径。
1.1.1.1. URL 参数串联 复制链接链接已复制到粘贴板!
启动新的工作区的 URL 支持使用 &
amp; 及以下 URL 语法连接多个可选 URL 参数:
https:// <openshift_dev_spaces_fqdn> #?<url_parameter_1> & <url_parameter_2> & <url_parameter_3>
例 1.6. 使用 Git 存储库的 URL 和可选 URL 参数启动新工作区的 URL
浏览器的完整 URL:
https:// <openshift_dev_spaces_fqdn>#https://github.com/che-samples/cpp-hello-world?new&che-editor=che-incubator/intellij-community/latest&devfilePath=tests/testdevfile.yaml
URL 的部分解释:
https://<openshift_dev_spaces_fqdn> #https://github.com/che-samples/cpp-hello-world ?new&che-editor=che-incubator/intellij-community/latest&devfilePath=tests/testdevfile.yaml
https://<openshift_dev_spaces_fqdn>
#https://github.com/che-samples/cpp-hello-world
?new&che-editor=che-incubator/intellij-community/latest&devfilePath=tests/testdevfile.yaml
1.1.1.2. IDE 的 URL 参数 复制链接链接已复制到粘贴板!
您可以在启动工作区时,使用 che-editor=
URL 参数指定受支持的 IDE。
当您无法在 source-code Git 仓库中添加或编辑要克隆的 source-code Git 存储库中的 /.che/che-editor.yaml
文件时,请使用 che-editor=
参数。
che-editor=
参数覆盖 /.che/che-editor.yaml
文件。
这个参数接受两种类型的值:
che-editor=<editor_key>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?che-editor=<editor_key>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?che-editor=<editor_key>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expand 表 1.1. 支持的 IDE 的 URL 参数 <editor_key > 值 IDE <editor_key>
value备注 che-incubator/che-code/latest
这是在使用 URL 参数或
che-editor.yaml
时,在新工作区中载入的默认 IDE。che-editor=<url_to_a_file>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?che-editor=<url_to_a_file>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?che-editor=<url_to_a_file>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 指向包含 devfile 内容的 文件的 URL。
提示- URL 必须指向原始文件内容。
-
要将此参数与
che-editor.yaml
文件一起使用,请使用另一个名称或路径复制该文件,并从文件中删除内联
行。
- che-editors.yaml 文件包含 所有支持的 IDE 的 devfile。
1.1.1.3. IDE 镜像的 URL 参数 复制链接链接已复制到粘贴板!
您可以使用 editor-image
参数为工作区设置自定义 IDE 镜像。
-
如果 Git 存储库包含
/.che/che-editor.yaml
文件,则自定义编辑器将使用新的 IDE 镜像覆盖。 -
如果 Git 存储库中没有
/.che/che-editor.yaml
文件,则默认的编辑器将使用新的 IDE 镜像覆盖。 -
如果要覆盖支持的 IDE 并更改目标编辑器镜像,您可以同时使用这两个参数:
che-editor
和editor-image
URL 参数。
覆盖 IDE 镜像的 URL 参数是 editor-image=
:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?editor-image=<container_registry/image_name:image_tag>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?editor-image=<container_registry/image_name:image_tag>
Example:
https:// <openshift_dev_spaces_fqdn>#https://github.com/eclipse-che/che-docs?editor-image=quay.io/che-incubator/che-code:next
or
https:// <openshift_dev_spaces_fqdn>#https://github.com/eclipse-che/che-docs?che-editor=che-incubator/che-code/latest&editor-image=quay.io/che-incubator/che-code:next
1.1.1.4. 用于启动重复工作区的 URL 参数 复制链接链接已复制到粘贴板!
访问用于启动新的工作区的 URL 会根据 devfile 和链接 Git 存储库的克隆产生一个新的工作区。
在某些情况下,您可能需要有多个在 devfile 和链接的 Git 仓库中重复的工作区。您可以通过访问同一 URL 来使用 URL 参数启动新工作区来完成此操作。
用于启动重复工作区的 URL 参数是 新的
:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?new
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?new
如果您目前有一个使用 URL 启动的工作区,那么在没有 新
URL 参数的情况下再次访问 URL 会导致错误消息。
1.1.1.5. devfile 文件名的 URL 参数 复制链接链接已复制到粘贴板!
当您访问 URL 来启动新的工作区时,OpenShift Dev Spaces 将链接的 Git 存储库搜索带有文件名 .devfile.yaml
或 devfile.yaml
的 devfile。链接 Git 存储库中的 devfile 必须遵循此文件命名惯例。
在某些情况下,您可能需要为 devfile 指定不同的、不协调的文件名。
用于指定 devfile 的 unconventional 文件名的 URL 参数为 df= <filename>.yaml
:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?df=<filename>.yaml
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?df=<filename>.yaml
- 1
<filename > .yaml
是链接 Git 存储库中的 devfile 的 unconventional 文件名。
df= <filename> .yaml
参数也有一个长版本: devfilePath= <filename>.yaml
。
1.1.1.6. devfile 文件路径的 URL 参数 复制链接链接已复制到粘贴板!
当您访问 URL 来启动新的工作区时,OpenShift Dev Spaces 会在链接 Git 存储库的根目录中搜索名为 .devfile.yaml
或 devfile.yaml
的 devfile。链接 Git 存储库中的 devfile 的文件路径必须遵循此路径惯例。
在某些情况下,您可能需要在链接的 Git 存储库中为 devfile 指定不同的、不协调的文件路径。
用于指定 devfile 的 unconventional 文件路径的 URL 参数是 devfilePath= <relative_file_path>
:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?devfilePath=<relative_file_path>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?devfilePath=<relative_file_path>
- 1
<relative_file_path
> 是链接 Git 存储库中的 devfile 的 unconventional 文件路径。
1.1.1.7. 工作区存储的 URL 参数 复制链接链接已复制到粘贴板!
如果用于启动新工作区的 URL 不包含指定存储类型的 URL 参数,则新的工作区会在临时存储或持久性存储中(以 CheCluster
自定义资源中定义为默认存储类型)。
用于为工作区指定存储类型的 URL 参数是 storage Type= <storage_type>
:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?storageType=<storage_type>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?storageType=<storage_type>
- 1
- 可能的 <
;storage_type>
; 值:-
ephemeral
-
每个用户
(永久) -
per-workspace
(persistent)
-
使用 ephemeral
或 per-workspace
存储类型,您可以同时运行多个工作区,这无法进行 按用户的默认
存储类型。
其他资源
1.1.1.8. 其他远程的 URL 参数 复制链接链接已复制到粘贴板!
当您访问一个 URL 来启动新的工作区时,OpenShift Dev Spaces 会将 origin
远程配置为 Git 存储库,您在您的机构 OpenShift Dev Spaces 实例的 FQDN URL 后指定 #
。
用于克隆并为工作区配置额外远程的 URL 参数是 remotes=
:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?remotes={{<name_1>,<url_1>},{<name_2>,<url_2>},{<name_3>,<url_3>},...}
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?remotes={{<name_1>,<url_1>},{<name_2>,<url_2>},{<name_3>,<url_3>},...}
-
如果您没有为任何其他远程输入名称
origin
,则来自 <git_repository_url> 的远程会被克隆,并默认命名为origin
,并会作为自动签出的预期分支。 -
如果您为一个额外的远程输入了名称
origin
,它的默认分支将被自动签出,当来自 <git_repository_url> 的远程将不会为工作区进行克隆。
1.1.1.9. 容器镜像的 URL 参数 复制链接链接已复制到粘贴板!
在以下情况下,您可以使用 image
参数对容器镜像使用自定义引用:
- Git 存储库不包含 devfile,您希望使用自定义镜像启动新的工作区。
-
Git 存储库包含一个 devfile,您想要覆盖 devfile 的
components
部分中列出的第一个容器镜像。
容器镜像路径的 URL 参数是 image=
:
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?image=<container_image_url>
https://<openshift_dev_spaces_fqdn>#<git_repository_url>?image=<container_image_url>
Example
https:// <openshift_dev_spaces_fqdn>#https://github.com/eclipse-che/che-docs?image=quay.io/devfile/universal-developer-image:ubi8-latest