Usar compiladores personalizados y aportados por la comunidad
Organízate con las colecciones
Guarda y clasifica el contenido según tus preferencias.
En esta página se explica cómo usar compiladores aportados por la comunidad y compiladores personalizados en Cloud Build. La comunidad de desarrolladores de Cloud Build proporciona compiladores de código abierto que puedes usar para ejecutar tus tareas. Si la tarea que quieres realizar requiere funciones que no proporciona una imagen, puedes crear tu propia imagen personalizada y usarla en un paso de compilación. Para obtener información sobre los distintos tipos de compiladores, consulta Compiladores de Cloud.
Las imágenes precompiladas no están disponibles para los compiladores de la comunidad. Para usar estos compiladores en un archivo de configuración de Cloud Build, primero debes compilar la imagen y enviarla a Artifact Registry en tu proyecto.
Para usar un creador aportado por la comunidad, sigue estos pasos:
Estos son algunos ejemplos de situaciones en las que puede ser útil usar una imagen de compilación personalizada:
Descargar código fuente o paquetes de ubicaciones externas.
Usar una cadena de herramientas externa.
Almacenando en caché las bibliotecas necesarias.
Compilación previa de la fuente (Cloud Build solo se encarga de empaquetar la compilación en una imagen).
Al igual que cualquier otro creador, un creador personalizado se ejecuta con la fuente montada en /workspace y con un directorio de trabajo en /workspace. Los archivos que queden en /workspace después de un paso de compilación determinado estarán disponibles para otros pasos de compilación.
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-21 (UTC)."],[[["\u003cp\u003eCloud Build allows the use of community-contributed builders, which are open-source tools provided by the developer community, after building and pushing them to Container Registry.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize a community-contributed builder, clone the \u003ccode\u003ecloud-builders-community\u003c/code\u003e repository, navigate to the desired builder's directory, submit it using \u003ccode\u003egcloud builds submit\u003c/code\u003e, and then reference it in your Cloud Build config file.\u003c/p\u003e\n"],["\u003cp\u003eCustom builders can be created and used when existing builders do not meet specific task requirements, such as downloading external code, using external toolchains, or pre-building source code.\u003c/p\u003e\n"],["\u003cp\u003eCreating a custom builder involves defining a \u003ccode\u003eDockerfile\u003c/code\u003e, building and pushing it to Container Registry, and then specifying the image in the \u003ccode\u003ename\u003c/code\u003e field of a Cloud Build step.\u003c/p\u003e\n"],["\u003cp\u003eContainer Registry, which is used to store the builders, is scheduled for shutdown on March 18, 2025 and organizations which have not used it prior to January 8, 2024 will have new repositories hosted on Artifact Registry by default.\u003c/p\u003e\n"]]],[],null,["# Using community-contributed builders and custom builders\n\nThis page explains how to use [community-contributed builders](https://github.com/GoogleCloudPlatform/cloud-builders-community) and custom builders in Cloud Build. The\nCloud Build developer community provides [open-source\nbuilders](https://github.com/GoogleCloudPlatform/cloud-builders-community)\nthat you can use to execute your tasks. If the task you want to perform requires\ncapabilities that are not provided by an existing image, you can build your own\ncustom image and use it in a build step. To learn about the different types of\nbuilders, see [Cloud Builders](/build/docs/cloud-builders).\n\nIf you're new to Cloud Build, read the [quickstarts](/build/docs/quickstarts)\nand the [Build configuration overview](/build/docs/build-config) first.\n\nUsing community-contributed builders\n------------------------------------\n\nPrebuilt images are not available for community-contributed builders; to use\nthese builders in a Cloud Build config file, you must first build the\nimage and push it to [Artifact Registry](/artifact-registry/docs/overview) in\nyour project.\n\nTo use a community-contributed builder:\n\n1. Build and push the builder:\n\n 1. Navigate to your project root directory.\n\n 2. Clone the [cloud-builders-community](https://github.com/GoogleCloudPlatform/cloud-builders-community) repository:\n\n git clone https://github.com/GoogleCloudPlatform/cloud-builders-community.git\n\n 3. Navigate to the builder image you want to use, where \u003cvar translate=\"no\"\u003ebuilder-name\u003c/var\u003e\n is the directory that contains the builder:\n\n cd cloud-builders-community/\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ebuilder\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003ename\u003c/span\u003e\u003c/var\u003e\n\n 4. Submit the builder to your project:\n\n gcloud builds submit .\n\n 5. Navigate back to your project root directory:\n\n cd ../..\n\n 6. Remove the repository from your root directory:\n\n rm -rf cloud-builders-community/\n\n2. In your Cloud Build config file, use the builder in a build step:\n\n ### YAML\n\n steps:\n - name: 'gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/\u003cvar translate=\"no\"\u003ebuilder-name\u003c/var\u003e'\n args: ['\u003cvar translate=\"no\"\u003earg1\u003c/var\u003e', '\u003cvar translate=\"no\"\u003earg2\u003c/var\u003e', ...]\n ...\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/\u003cvar translate=\"no\"\u003ebuilder-name\u003c/var\u003e\",\n \"args\": [\n \"\u003cvar translate=\"no\"\u003earg1\u003c/var\u003e\",\n \"\u003cvar translate=\"no\"\u003earg2\u003c/var\u003e\",\n ...\n ]\n ...\n }\n ]\n }\n\n3. Use the build config file to start the [build manually](/build/docs/running-builds/start-build-manually)\n or [build using triggers](/build/docs/automating-builds/create-manage-triggers).\n\nFor examples on using community-contributed builders, see\n[Deploy to Firebase](/build/docs/deploying-builds/deploy-firebase)\nand [Build VM images using Packer](/build/docs/building/build-vm-images-with-packer).\n\nCreating a custom builder\n-------------------------\n\nIf the task you want to perform requires capabilities that are not provided by\n[a public image, a supported builder, or a community-contributed builder](/build/docs/cloud-builders),\nyou can build your own image and use it in a build step.\n\nSome examples of when you might want to use a custom builder image are:\n\n- Downloading source code or packages from external locations.\n- Using an external tool chain.\n- Caching any necessary libraries.\n- Pre-building source (with Cloud Build responsible only for potentially packaging the build into an image).\n\nLike any other builder, a custom builder runs with the source mounted under\n`/workspace`, and is run with a working directory in `/workspace`. Any files left\nin `/workspace` by a given build step are available to other build steps.\n\nYour custom builder can push to or pull from a repository in\n[Artifact Registry](/artifact-registry/docs/overview) (hosted at `gcr.io/$PROJECT-NAME/`)\nto which your [build service account](/build/docs/securing-builds/configure-user-specified-service-accounts) has\naccess.\n\nThe following steps show how to create and use a custom builder with an example\n`Dockerfile`:\n\n1. Create a custom builder image:\n\n 1. Create the `Dockerfile` for the custom builder. The following\n code shows an example `Dockerfile`:\n\n FROM alpine\n RUN apk add curl\n CMD curl https://httpbin.org/ip -s \u003e myip.txt; echo \"*** My IP is: $(cat myip.txt)\"\n\n 2. Build and push the custom builder to the Artifact Registry in your project,\n replacing values for \u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e and \u003cvar translate=\"no\"\u003eimage-name\u003c/var\u003e:\n\n gcloud builds submit --tag gcr.io/\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eproject\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eid\u003c/span\u003e\u003c/var\u003e/\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eimage\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003ename\u003c/span\u003e\u003c/var\u003e\n\n2. Use the custom builder image in Cloud Build by specifying the builder\n in the `name` field of a build step:\n\n ### YAML\n\n steps:\n - name: 'gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/\u003cvar translate=\"no\"\u003eimage-name\u003c/var\u003e'\n id: Determine IP of this build worker\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/\u003cvar translate=\"no\"\u003eimage-name\u003c/var\u003e\",\n \"id\": \"Determine IP of this build worker\"\n }\n ]\n }\n\n3. Use the build config file to start the [build manually](/build/docs/running-builds/start-build-manually)\n or [build using triggers](/build/docs/automating-builds/create-manage-triggers).\n\n| **Note:** Users can specify a working directory using the `dir` field in a build config file. Because your custom builder's users may specify any `dir` value, the builder should avoid hard-coding `/workspace` if possible. Instead, use the current working directory and relative paths.\n\nWhat's next\n-----------\n\n- Learn how to [run bash scripts in build steps](/build/docs/configuring-builds/run-bash-scripts).\n- Learn how to [configure build step order](/build/docs/configuring-builds/configure-build-step-order).\n- Learn how to [write a basic build config file](/build/docs/configuring-builds/create-basic-configuration)."]]