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:

  • 环境的用途。

¥The purpose of environments.

  • n8n 中的环境如何运作。

¥How environments work in n8n.

环境:什么是……为什么#

¥Environments: What and why

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

¥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:

  • 开发环境:执行工作并进行更改。

¥Development: do work and make changes.

  • 生产:生产环境。

¥Production: the live environment.

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

¥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 实例中构建和运行工作流。

¥The n8n instance is where you build and run workflows.

  • Git 分支存储工作流副本、标签以及变量和凭据存根。

¥The Git branch stores copies of the workflows, as well as tags, and variable and credential stubs.

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 分支,然后将更新拉取到另一个实例。

¥Multiple instances, one branch: you can push from one instance to the Git branch, then pull the work to another instance.

  • 多个实例,多个分支你需要创建一个拉取请求,并将其合并到你的 Git 提供商处。例如,如果你有开发、测试和生产分支,每个分支都链接到各自的实例,则需要将开发分支合并到测试分支,以使开发实例中的工作可在测试实例上使用。有关部分自动化流程的步骤,请参阅 在不同环境间复制工作

¥Multiple instances, multiple branches: you need to create a pull request and merge in your Git provider. For example, if you have development, test, and production branches, each linked to their own instance, you need to merge the development branch into test to make the work from the development instance available on the test instance. Refer to Copy work between environments for more information, including steps to partially automate the process.

有关推送和拉取工作的详细指南,请参阅 推送和拉取

¥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.