이 페이지에서는 빌드 종속 항목을 지정하는 방법을 설명합니다. Cloud Build를 사용하면 빌드 프로세스와 별도로 소스 코드 종속 항목을 관리할 수 있습니다.
빌드 구성 파일에서 빌드를 위해 클론할 하나 이상의 Git 저장소와 가져올 순서를 나열할 수 있습니다. 이러한 방식으로 종속 항목을 지정하면 종속 항목 가져오기가 빌드 프로세스 자체에서 분리됩니다.
빌드 구성 파일에 종속 항목을 포함하지 않으면 Cloud Build는 빌드 구성 파일이 포함된 소스 코드 저장소 (트리거된 빌드의 경우) 또는 소스 코드가 포함된 저장소 (명령줄에서 호출하는 빌드의 경우)를 클론합니다. 빌드 구성 파일에 종속 항목을 포함하는 경우 Cloud Build는 dependencies 필드에 지정되지 않은 저장소를 클론하지 않습니다.
dependencies 필드에 지정하는 소스 코드 저장소는 Developer Connect를 사용하여 Cloud Build에 연결되어 있거나 공개 저장소여야 합니다.
종속 항목은 이 구성에 지정한 순서대로 클론됩니다. 또한 종속 항목 가져오기는 사용자 지정 로직이 실행되기 전에 발생합니다. 따라서 종속 항목 가져오기는 신뢰할 수 있습니다.
종속 항목은 빌드 세부정보 페이지의 빌드 종속 항목 탭에 표시됩니다.
시작하기 전에
이 페이지의 안내에서는 하나 이상의 Git 저장소가 공개 저장소이거나 Developer Connect를 사용하여 연결되어 있다고 가정합니다.
Developer Connect 저장소를 종속 항목으로 추가하는 데 필요한 권한을 얻으려면 관리자에게 서비스 계정에 대한 Developer Connect 읽기 토큰 액세스 권한 (developerconnect.readTokenAccessor) IAM 역할을 부여해 달라고 요청하세요.
역할 부여에 대한 상세 설명은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.
URL 또는 리소스 경로를 지정해야 합니다. 가져올 저장소가 개발자 연결을 사용하여 Cloud Build에 연결된 경우 리소스 경로를 지정합니다.
다음 값을 바꿉니다.
URL: 선택사항. 가져올 저장소의 HTTPS URL입니다.
RESOURCE_PATH: 선택사항. Developer Connect 저장소의 Google Cloud 리소스 경로입니다. 예를 들면 projects/my-project/locations/us-central1/connections/my-connection/gitRepositoryLinks/my-repo입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eCloud Build allows you to manage and specify source-code dependencies separately from the build process by listing Git repositories in your build configuration file.\u003c/p\u003e\n"],["\u003cp\u003eIf no dependencies are listed, Cloud Build will clone the source code repository containing the build configuration, but if dependencies are specified, only those repositories will be cloned.\u003c/p\u003e\n"],["\u003cp\u003eDependencies in your configuration file must be either public repositories or connected to Cloud Build via Developer Connect, and they are cloned in the order specified before any build logic executes.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edependencies\u003c/code\u003e stanza in the build configuration file is where you list the repositories, specifying details like the URL or Developer Connect resource path, revision, submodule settings, depth, and destination path.\u003c/p\u003e\n"],["\u003cp\u003eIf using a Developer Connect repository, ensure that the Cloud Build service account has the \u003ccode\u003eDeveloper Connect Read Token Accessor\u003c/code\u003e role and that the build is in the same region as the Developer Connect connection.\u003c/p\u003e\n"]]],[],null,["# Manage build dependencies\n\nThis page explains how you can specify build dependencies. Cloud Build\nlets you manage source-code dependencies separately from the build process.\n\nIn your build configuration file, you can list one or more Git repositories to\nclone for your build, and the order in which to fetch them. Specifying\ndependencies in this way separates dependency fetching from the build\nprocess itself.\n\nIf you don't include any dependencies in your build configuration file,\nCloud Build clones the source code repository that contains your build\nconfiguration file (for triggered builds) or the repository that contains your\nsource code (for builds that you invoke from the command line). If you do\ninclude dependencies in your build configuration file, Cloud Build\ndoesn't clone any repositories that aren't specified in the `dependencies`\nfield.\n\nAny source code repository you specify in the `dependencies` field must be\nconnected to Cloud Build using Developer Connect, or else\nbe a public repository.\n\nDependencies are cloned in the order that you specify them in this\nconfiguration. Also, dependency fetching occurs before any user-specified logic\nis executed. Thus, dependency fetching is trusted.\n\nDependencies are shown in the **Build dependencies** tab of the\n**Build details** page.\n\nBefore you begin\n----------------\n\nThe instructions on this page assume that you have one or more Git repositories\nthat are either public repositories or are\n[linked](/developer-connect/docs/connect-github-repo) using\nDeveloper Connect.\n\n\nTo get the permissions that\nyou need to add a Developer Connect repository as a dependency,\n\nask your administrator to grant you the\n\n\nDeveloper Connect Read Token Accessor (`developerconnect.readTokenAccessor`)\nIAM role on your service account.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nSpecify dependencies\n--------------------\n\nYou specify dependencies by adding a `dependencies` stanza to your build\nconfiguration file. `dependencies` is a top-level property in the build config,\nbut you can put it anywhere in the file.\n\nThe following is the syntax for the `dependencies` stanza: \n\n### YAML\n\n dependencies:\n - gitSource:\n repository:\n url: '\u003cvar translate=\"no\"\u003eURL\u003c/var\u003e'\n developerConnect: '\u003cvar translate=\"no\"\u003eRESOURCE_PATH\u003c/var\u003e'\n revision: '\u003cvar translate=\"no\"\u003eREVISION\u003c/var\u003e'\n recurseSubmodules: '\u003cvar translate=\"no\"\u003etrue|false\u003c/var\u003e'\n depth: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDEPTH\u003c/span\u003e\u003c/var\u003e'\n destPath: '\u003cvar translate=\"no\"\u003eDEST_PATH\u003c/var\u003e'\n\n### JSON\n\n {\n \"dependencies\": {\n \"gitSource\": {\n \"repository\": {\n \"url\": \"\u003cvar translate=\"no\"\u003eURL\u003c/var\u003e\"\n \"developerConnect\": \"\u003cvar translate=\"no\"\u003eRESOURCE_PATH\u003c/var\u003e\"\n },\n \"revision\": \"\u003cvar translate=\"no\"\u003eREVISION\u003c/var\u003e\",\n \"recurseSubmodules\": \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-kc\"\u003etrue\u003c/span\u003e\u003cspan class=\"devsite-syntax-err\"\u003e|\u003c/span\u003e\u003cspan class=\"devsite-syntax-kc\"\u003efalse\u003c/span\u003e\u003c/var\u003e,\n \"depth\": \"\u003cvar translate=\"no\"\u003eDEPTH\u003c/var\u003e\",\n \"destPath\": \"\u003cvar translate=\"no\"\u003eDEST_PATH\u003c/var\u003e\",\n },\n },\n }\n\nYou must specify either a URL or a resource path. Specify a resource path if\nthe repository to fetch is connected to Cloud Build using\nDeveloper Connect.\n\nReplace the following values:\n\n- \u003cvar translate=\"no\"\u003eURL\u003c/var\u003e: Optional. The HTTPS URL of the repository to fetch.\n- \u003cvar translate=\"no\"\u003eRESOURCE_PATH\u003c/var\u003e: Optional. The Google Cloud resource\n path to a Developer Connect repository. For example,\n `projects/my-project/locations/us-central1/connections/my-connection/gitRepositoryLinks/my-repo`.\n\n- \u003cvar translate=\"no\"\u003eREVISION\u003c/var\u003e: Required. The version, commit hash, tag, or\n branch name to fetch from the repository.\n\n- `recurseSubmodules`: '\u003cvar translate=\"no\"\u003etrue|false\u003c/var\u003e': Whether to fetch\n submodules.\n\n- \u003cvar translate=\"no\"\u003eDEPTH\u003c/var\u003e: Optional, how deep into the repository history\n to fetch. If not specified, the latest commit is fetched.\n\n - `1`: the latest commit\n - `2`: the last two commits\n - `3`: the last three commits\n - `-1`: all commits\n- \u003cvar translate=\"no\"\u003eDEST_PATH\u003c/var\u003e: Required. The path to the directory into\n which the repository is cloned. For example, `my/repo`.\n\n When you set the `dest_path` the repository is fetched in\n `/workspace/\u003cdest_path\u003e`. The `dest_path` value must be a path relative to the\n working directory of the build.\n\nSpecify a Developer Connect repository as a dependency\n------------------------------------------------------\n\n- If you specify a Developer Connect repository as a dependency, then\n you must grant the `Developer Connect Read Token Accessor` role to the\n Cloud Build service account. For more information, see\n [Grant Cloud Build access to a Developer Connect repository](/developer-connect/docs/repositories/connect-repository#grant-access).\n\n- Your build must be in the same region as the Developer Connect\n connection.\n\nWhat's next\n-----------\n\n- Learn how to [connect a repository to Cloud Build using\n Cloud Build repositories](/build/docs/repositories).\n\n- Learn how to [connect a repository to Cloud Build using\n Developer Connect](/developer-connect/docs/overview)."]]