Skip to main content

此版本的 GitHub Enterprise 已停止服务 2022-06-03. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

Adding self-hosted runners

You can add a self-hosted runner to a repository, an organization, or an enterprise.

注: GitHub 托管的运行器目前在 GitHub Enterprise Server 上不受支持。 您可以在 GitHub 公共路线图 上查看有关未来支持计划的更多信息。

You can add a self-hosted runner to a repository, an organization, or an enterprise.

If you are an organization or enterprise administrator, you might want to add your self-hosted runners at the organization or enterprise level. This approach makes the runner available to multiple repositories in your organization or enterprise, and also lets you to manage your runners in one place.

For information on supported operating systems for self-hosted runners, or using self-hosted runners with a proxy server, see "About self-hosted runners."

Warning: 建议仅将自托管运行器用于私有仓库。 这是� 为,通过创建在工作流程中执行代� �的拉取请求,仓库的复刻可能会在您的自托管运行器上运行危险代� �。

For more information, see "About self-hosted runners."

Prerequisites

  • GitHub Actions must be enabled for GitHub Enterprise Server. A site administrator can enable and configure GitHub Actions for your instance. For more information, see "Getting started with GitHub Actions for GitHub Enterprise Server."

  • You must have access to the machine you will use as a self-hosted runner in your environment.

  • 自托管运行器与 GitHub Enterprise Server 之间的连接通过HTTP(端口 80)或 HTTPS(端口 443)。 要确保通过 HTTPS 的连接,请为 您的 GitHub Enterprise Server 实例 配置 TLS。 更多信息请参阅“配置 TLS”。 For more information, see "About self-hosted runners."

Adding a self-hosted runner to a repository

You can add self-hosted runners to a single repository. To add a self-hosted runner to a user repository, you must be the repository owner. For an organization repository, you must be an organization owner or have admin access to the repository. For information about how to add a self-hosted runner with the REST API, see "Self-hosted runners."

  1. 在 您的 GitHub Enterprise Server 实例 上,导航到仓库的主页面。

  2. 在仓库名称下,单击 Settings(设置)仓库设置按钮

  3. In the left sidebar, click Actions.

  4. Under "Self-hosted runners", click Add runner.

  5. Select the operating system image and architecture of your self-hosted runner machine.

  6. 您将看到指示您如何下载运行器应用程序并安装到自托管运行器机器上的说明。

    在自托管运行器机器上打开 shell,并按显示的顺序运行每个 shell 命令。

    注意: 在 Windows上,如果要将自托管运行器应用程序安装为服务,必须打开具有管理员权限的 shell。 我们还建议您使用 C:\actions-runner 作为自托管运行器应用程序的目录,以便 Windows 系统帐户可以访问运行器目录。

    这些说明将指导您完成以下任务:

    • 下载并提取自托管运行器应用程序。
    • 运行 config 脚本配置自托管运行器应用程序,并向 GitHub Actions 注册。 config 脚本需要目� � URL 和自动生成的时间限制令牌来验证请求。
      • 在 Windows上,config 脚本还会询问您是否想将自托管运行器应用程序安装为服务。 对于 Linux 和 macOS,您可以在完成添� 运行器后安装服务。 更多信息请参阅“将自托管运行器应用程序配置为服务”。
    • 运行自托管运行器应用程序以将机器连接到 GitHub Actions。

检查您的自托管运行器是否已成功添� 

After completing the steps to add a self-hosted runner, the runner and its status are now listed under "Self-hosted runners".

必须激活自托管运行器应用程序,运行器才能接受作业。 When the runner application is connected to GitHub Enterprise Server and ready to receive jobs, you will see the following message on the machine's terminal.

√ 已连接到 GitHub

2019-10-24 05:45:56Z: 正在监听作业

For more information, see "Monitoring and troubleshooting self-hosted runners."

Adding a self-hosted runner to an organization

You can add self-hosted runners at the organization level, where they can be used to process jobs for multiple repositories in an organization. To add a self-hosted runner to an organization, you must be an organization owner. For information about how to add a self-hosted runner with the REST API, see "Self-hosted runners."

  1. 在 您的 GitHub Enterprise Server 实例 上,导航到组织的主页面。

  2. 在组织名称下,单击 设置.

    组织设置按钮

  3. In the left sidebar, click Actions.

  4. Under "Self-hosted runners", click Add runner."

  5. Select the operating system image and architecture of your self-hosted runner machine.

  6. 您将看到指示您如何下载运行器应用程序并安装到自托管运行器机器上的说明。

    在自托管运行器机器上打开 shell,并按显示的顺序运行每个 shell 命令。

    注意: 在 Windows上,如果要将自托管运行器应用程序安装为服务,必须打开具有管理员权限的 shell。 我们还建议您使用 C:\actions-runner 作为自托管运行器应用程序的目录,以便 Windows 系统帐户可以访问运行器目录。

    这些说明将指导您完成以下任务:

    • 下载并提取自托管运行器应用程序。
    • 运行 config 脚本配置自托管运行器应用程序,并向 GitHub Actions 注册。 config 脚本需要目� � URL 和自动生成的时间限制令牌来验证请求。
      • 在 Windows上,config 脚本还会询问您是否想将自托管运行器应用程序安装为服务。 对于 Linux 和 macOS,您可以在完成添� 运行器后安装服务。 更多信息请参阅“将自托管运行器应用程序配置为服务”。
    • 运行自托管运行器应用程序以将机器连接到 GitHub Actions。

检查您的自托管运行器是否已成功添� 

After completing the steps to add a self-hosted runner, the runner and its status are now listed under "Self-hosted runners".

必须激活自托管运行器应用程序,运行器才能接受作业。 When the runner application is connected to GitHub Enterprise Server and ready to receive jobs, you will see the following message on the machine's terminal.

√ 已连接到 GitHub

2019-10-24 05:45:56Z: 正在监听作业

For more information, see "Monitoring and troubleshooting self-hosted runners."

注意:出于安全原� ,公共仓库默认不能在运行器组中使用运行器,但您可以在运行器组的设置中覆盖此项。 更多信息请参阅“使用组管理对自托管运行器的访问”。

Adding a self-hosted runner to an enterprise

You can add self-hosted runners to an enterprise, where they can be assigned to multiple organizations. The organization admins are then able to control which repositories can use it.

New runners are assigned to the default group. You can modify the runner's group after you've registered the runner. For more information, see "Managing access to self-hosted runners."

要将自托管的运行器添� 到企业,您必须是组织所有者。

  1. 在 GitHub Enterprise Server 的右上角,单击您的个人资料照片,然后单击 Enterprise settings(Enterprise 设置)GitHub Enterprise Server 上个人资料照片下拉菜单中的"Enterprise settings(企业设置)"

  2. 在企业账户侧边� �中,单击 Policies(政策)企业帐户侧边� �中的 Policies(政策)选项卡

  3. 在“ Policies(政策)”下,单击 Actions(操作)

  4. 单击 自托管运行器 选项卡。

  5. 单击 Add new(新增),然后单击 New runner(新运行器)

  6. Select the operating system image and architecture of your self-hosted runner machine.

  7. 您将看到指示您如何下载运行器应用程序并安装到自托管运行器机器上的说明。

    在自托管运行器机器上打开 shell,并按显示的顺序运行每个 shell 命令。

    注意: 在 Windows上,如果要将自托管运行器应用程序安装为服务,必须打开具有管理员权限的 shell。 我们还建议您使用 C:\actions-runner 作为自托管运行器应用程序的目录,以便 Windows 系统帐户可以访问运行器目录。

    这些说明将指导您完成以下任务:

    • 下载并提取自托管运行器应用程序。
    • 运行 config 脚本配置自托管运行器应用程序,并向 GitHub Actions 注册。 config 脚本需要目� � URL 和自动生成的时间限制令牌来验证请求。
      • 在 Windows上,config 脚本还会询问您是否想将自托管运行器应用程序安装为服务。 对于 Linux 和 macOS,您可以在完成添� 运行器后安装服务。 更多信息请参阅“将自托管运行器应用程序配置为服务”。
    • 运行自托管运行器应用程序以将机器连接到 GitHub Actions。

检查您的自托管运行器是否已成功添� 

After completing the steps to add a self-hosted runner, the runner and its status are now listed under "Self-hosted runners".

必须激活自托管运行器应用程序,运行器才能接受作业。 When the runner application is connected to GitHub Enterprise Server and ready to receive jobs, you will see the following message on the machine's terminal.

√ 已连接到 GitHub

2019-10-24 05:45:56Z: 正在监听作业

For more information, see "Monitoring and troubleshooting self-hosted runners."

注意:出于安全原� ,公共仓库默认不能在运行器组中使用运行器,但您可以在运行器组的设置中覆盖此项。 更多信息请参阅“使用组管理对自托管运行器的访问”。

Making enterprise runners available to repositories

By default, runners in an enterprise's "Default" self-hosted runner group are available to all organizations in the enterprise, but are not available to all repositories in each organization.

To make an enterprise-level self-hosted runner group available to an organization repository, you might need to change the organization's inherited settings for the runner group to make the runner available to repositories in the organization.

For more information on changing runner group access settings, see "Managing access to self-hosted runners using groups."

Further reading