Skip to content

n8n 中的环境(Environments in n8n)#

n8n 在 Git(一种版本控制软件)的基础上构建了其环境功能。本文档帮助你了解:

🌐 n8n has built its environments feature on top of Git, a version control software. This document helps you understand:

  • 环境的用途。
  • n8n 中的环境如何运作。

环境:什么以及为什么(Environments: What and why)#

在软件开发中,环境指的是围绕代码的所有基础设施和工具,包括运行软件的工具,以及这些工具的特定配置。有关软件开发环境的更多详细介绍,请参阅 Codecademy | Environments

🌐 In software development, the environment is all the infrastructure and tooling around the code, including the tools that run the software, and the specific configuration of those tools. For a more detailed introduction to environments in software development, refer to Codecademy | Environments.

在 n8n 中,低代码开发也是类似的。n8n 是你构建和运行工作流的地方。你的实例可能有特定的配置:在云端,n8n 会确定配置;在自托管实例上,有广泛的配置选项。你也可能更改了实例的设置。这种 n8n 与实例的特定配置和设置相结合,构成了你的工作流运行的环境。

🌐 Low-code development in n8n is similar. n8n is where you build and run your workflows. Your instance may have particular configurations: on Cloud, n8n determines the configuration. On self-hosted instances, there are extensive configuration options. You may also have made changes to the settings of your instance. This combination of n8n and your instance's specific configuration and settings is the environment your workflows run in.

拥有多个环境是有好处的。一个常见的模式是为开发和生产设置不同的环境:

🌐 There are advantages to having more than one environment. A common pattern is to have different environments for development and production:

  • 开发:进行工作并进行修改。
  • 生产环境:实时环境。

这样的设置有助于你在不中断正在使用的工作流的情况下更改工作流。

🌐 A setup like this helps you make changes to workflows without breaking workflows that are in use.

n8n 中的环境(Environments in n8n)#

在 n8n 中,一个环境包含两部分:n8n 实例和 Git 分支。

🌐 In n8n, an environment comprises two parts, an n8n instance and a Git branch:

  • 你可以在 n8n 实例中构建和运行工作流。
  • Git 分支存储工作流副本、标签以及变量和凭据存根。

n8n不会将凭证和变量值与Git同步。在设置新实例时,您必须手动设置凭证和变量值。更多信息,请参阅 推送和拉取 | 什么会被提交

🌐 n8n doesn't sync credentials and variable values with Git. You must set up the credentials and variable values manually when setting up a new instance. For more information, refer to Push and pull | What gets committed.

如何在不同环境之间复制工作取决于你的分支和 n8n 实例配置:

🌐 How you copy work between environments depends on your branch and n8n instance configuration:

  • 多个实例,一个分支:你可以从一个实例推送到 Git 分支,然后将工作拉取到另一个实例。
  • 多个实例,多个分支:你需要在你的 Git 提供平台上创建拉取请求并进行合并。例如,如果你有开发、测试和生产分支,并且每个分支都链接到各自的实例,你需要将开发分支合并到测试分支,以使开发实例上的工作在测试实例上可用。有关更多信息,包括部分自动化流程的步骤,请参考 在环境之间复制工作

有关推动和拉动工作的详细指导,请参阅 Push and pull

🌐 For detailed guidance on pushing and pulling work, refer to Push and pull.

请参阅 设置源代码管理 以了解如何将你的 n8n 实例链接到 Git,或按照 教程:使用源代码管理创建环境 使用 n8n 推荐的配置之一来设置你的环境。

🌐 Refer to Set up source control to learn more about linking your n8n instance to Git, or follow the Tutorial: Create environments with source control to set up your environments using one of n8n's recommended configurations.