

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 關於 CodeBuild 託管的 GitLab Runner
<a name="gitlab-runner-questions"></a>

以下是有關 CodeBuild 託管 GitLab 執行器的一些常見問題。

## CodeBuild 託管的 GitLab 執行器支援哪些來源類型？
<a name="gitlab-runner-source"></a>

`GITLAB` 和`GITLAB_SELF_MANAGED`來源類型支援 CodeBuild 託管的 GitLab 執行器。

## 我應該在標籤中何時包含映像和執行個體覆寫？
<a name="gitlab-runner-image-label"></a>

您可以在 標籤中包含映像和執行個體覆寫，以便為每個 GitLab CI/CD 管道任務指定不同的建置環境。這可以完成，無需建立多個 CodeBuild 專案或 Webhook。

## 我可以將 CloudFormation 用於此功能嗎？
<a name="gitlab-runner-cfn"></a>

是，您可以在 CloudFormation 範本中包含篩選條件群組，在專案 Webhook 中指定 GitLab 工作流程任務事件篩選條件。

```
Triggers:
  Webhook: true
  FilterGroups:
    - - Type: EVENT
        Pattern: WORKFLOW_JOB_QUEUED
```

如需詳細資訊，請參閱[篩選 GitLab Webhook 事件 (CloudFormation)](gitlab-webhook-events-cfn.md)。

如果您需要在 CloudFormation 範本中設定專案登入資料的說明，請參閱*AWS CloudFormation 《 使用者指南*》中的 [AWS::CodeBuild::SourceCredential](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-sourcecredential.html) 以取得詳細資訊。

## 使用此功能時，如何遮罩秘密？
<a name="gitlab-runner-secrets"></a>

根據預設，不會遮罩在日誌中列印的秘密。如果您想要遮罩秘密，您可以透過更新 CI/CD 環境變數設定來執行此操作：

**在 GitLab 中遮罩秘密**

1. 在您的 **GitLab 設定**中，選擇 **CI/CD**。

1. 在**變數**中，針對您要遮罩的秘密選擇**編輯**。

1. 在**可見性**中，選取**遮罩變數**，然後選擇**更新變數**以儲存變更。

## 我可以從單一群組中的多個專案接收 GitLab Webhook 事件嗎？
<a name="gitlab-runner-webhooks"></a>

CodeBuild 支援群組 Webhook，從指定的 GitLab 群組接收事件。如需詳細資訊，請參閱[GitLab 群組 Webhook](gitlab-group-webhook.md)。

## 我可以在 Docker 執行器中為自我管理的執行器執行任務嗎？ 例如，我想要在特定映像上執行管道任務，以在個別隔離的容器中維護相同的建置環境。
<a name="gitlab-runner-custom-image"></a>

您可以使用特定映像在 CodeBuild 中執行 GitLab 自我管理執行器[，方法是使用自訂映像建立專案](create-project.md#environment-image.console)，或[覆寫檔案中的映像](sample-gitlab-runners.md#sample-gitlab-runners-gitlab-ci)。 `.gitlab-ci.yml`

## CodeBuild 中的自我管理執行器會搭配哪些執行器執行？
<a name="gitlab-runner-shell-executor"></a>

CodeBuild 中的自我管理執行器會使用 shell 執行器執行，其中建置會在本機執行，並搭配在 Docker 容器內執行的 GitLab 執行器。

## 我可以提供 buildspec 命令與自我管理的執行器嗎？
<a name="gitlab-runner-buildspec-commands"></a>

是，您可以新增 buildspec 命令以及自我管理的執行器。您可以在 GitLab 儲存庫中提供 buildspec.yml 檔案，並在任務的**標籤**區段中使用 `buildspec-override:true`標籤。如需詳細資訊，請參閱[Buildspec 檔案名稱和儲存位置](build-spec-ref.md#build-spec-ref-name-storage)。

## 哪些區域支援使用 CodeBuild 託管的 GitLab 執行器？
<a name="gitlab-runner-hosted-regions"></a>

所有 CodeBuild 區域都支援 CodeBuild 託管的 GitLab 執行器。如需 CodeBuild 可用 AWS 區域 位置的詳細資訊，請參閱[AWS 依區域的服務](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/)。

## 哪些平台支援使用 CodeBuild 託管的 GitLab 執行器？
<a name="gitlab-runner-platform"></a>

Amazon EC2 和[AWS Lambda](lambda.md)運算都支援 CodeBuild 託管的 GitLab 執行器。您可以使用下列平台：Amazon Linux 2、Amazon Linux 2023、Ubuntu 和 Windows Server Core 2019。如需詳細資訊，請參閱[EC2 運算映像](ec2-compute-images.md)及[Lambda 運算映像](lambda-compute-images.md)。