Criar código manualmente em repositórios de origem
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, explicamos como criar gatilhos manuais para criar código
em repositórios de origem. Os acionadores manuais podem ser usados
para invocar versões manualmente. Assim, é possível modificar os valores das variáveis de substituição definidas
no momento da invocação antes de executá-las. Também é possível programar acionadores manuais para serem executados automaticamente em um horário específico.
Para saber como iniciar builds manualmente usando a CLI gcloud ou
a API Cloud Build, consulte
Como iniciar builds manualmente.
Os gatilhoes manuais permitem configurar versões que são executadas apenas
quando você invoca o gatilho em repositórios conectados. Digamos que você esteja criando
um pipeline para implantar seu código-fonte em um ambiente de teste ou produção.
É recomendável automatizar seu fluxo de trabalho, mas só pretende executar versões
manualmente. Você pode definir gatilhos manuais.
Os acionadores manuais permitem invocar manualmente as versões:
Buscando código-fonte de um repositório hospedado com um branch ou tag especificados.
Parametrizar seu build com substituições que não precisam ser transmitidas
manualmente sempre que você executa um build.
Como substituir valores de variáveis de substituição definidas no momento da invocação antes de
invocar uma versão.
Para executar builds do diretório de trabalho local em vez de um repositório hospedado
ou se quiser enviar builds sem criar um gatilho, execute o seguinte
comando gcloud no diretório de trabalho:
Se você selecionar global como a região,
o Cloud Build usará o pool
padrão para executar o build.
Se você selecionar uma região não global e o
arquivo de configuração de build associado ao gatilho
especificar um pool particular, o Cloud Build usará o pool
particular para executar o build. Nesse caso, a região especificada no gatilho precisa corresponder à região em que você criou o pool particular.
Se você selecionar uma região não global e o
arquivo de configuração de build associado ao gatilho
não especificar um pool particular,
o Cloud Build usará o pool
padrão para executar o build na mesma região
do gatilho.
Descrição (opcional): uma descrição do gatilho.
Evento: selecione Invocação manual para configurar o gatilho de modo que os builds
sejam executados somente quando o gatilho for invocado manualmente.
Origem: selecione o repositório a ser criado quando o gatilho manual for executado. É possível especificar 1ª geração ou 2ª geração como sua fonte.
Revisão: selecione a ramificação ou tag a ser criada quando o gatilho manual for
executado.
Filial: defina um gatilho para o build nesse branch.
É preciso especificar um valor literal. Expressões regulares não são compatíveis
no momento.
Tag: define um gatilho para o build nessa tag. É preciso especificar um valor
literal. Expressões regulares não são compatíveis no momento.
Configuração: selecione o arquivo de configuração do build localizado no
seu repositório remoto ou crie um arquivo de configuração do build inline para
usar no build.
Tipo: selecione o tipo de configuração a ser usado para seu build.
Arquivo de configuração do Cloud Build (yaml ou json):
use um arquivo de configuração do build na sua configuração.
Dockerfile: use um Dockerfile para sua configuração.
Local: especifique o local de configuração.
Repositório: se o arquivo de configuração estiver no seu
repositório remoto, forneça o local do arquivo de configuração do build, o diretório Dockerfile
ou o diretório buildpacks. Se o tipo de configuração do build
for um Dockerfile ou um buildpack, você precisará fornecer
um nome para a imagem resultante e, opcionalmente, um tempo limite para o seu
build. Depois de fornecer o nome da imagem Dockerfile ou do buildpack, você verá uma visualização do comando docker build ou
pack que seu build executará.
Inline: se você selecionou o
arquivo de configuração do Cloud Build (yaml ou json) como opção de configuração, pode especificar a configuração do build inline. Clique em Abrir editor para gravar o arquivo de configuração do build no console Google Cloud usando a sintaxe YAML ou JSON. Clique em Concluído para salvar a configuração do build.
Depois de clicar em Executar gatilho, você verá o painel Executar gatilho no
lado direito. Se tiver especificado campos como o nome da ramificação, da tag
ou das variáveis de substituição, será possível substituí-los
no momento da invocação.
Se você especificou novos valores de variáveis para a substituição, clique em Executar gatilho
para executar seu build.
Para executar gatilhos manuais dentro da programação, consulte
Como programar builds.
gcloud
Para executar um gatilho manual usando a ferramenta de linha de comando gcloud, execute o seguinte
comando:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[[["\u003cp\u003eManual triggers allow for the execution of builds on connected repositories only when the trigger is invoked, providing control over build timing.\u003c/p\u003e\n"],["\u003cp\u003eBuilds can be parameterized with substitution variables, which can be overridden at invocation time without requiring manual input each time.\u003c/p\u003e\n"],["\u003cp\u003eManual triggers can be created via the Google Cloud console or the \u003ccode\u003egcloud\u003c/code\u003e command-line tool, with options to specify source repository, branch, tag, and build configuration.\u003c/p\u003e\n"],["\u003cp\u003eRunning a manual trigger can be done through the console or the \u003ccode\u003egcloud\u003c/code\u003e command, and allows for overriding specified fields like branch names, tag names, or substitution variables.\u003c/p\u003e\n"],["\u003cp\u003eYou have the option to schedule manual triggers to run at a specific time, in addition to invoking them manually.\u003c/p\u003e\n"]]],[],null,["1st gen 2nd gen\n\nThis page explains how to create manual triggers to build code\nin source repositories. Manual triggers can be used\nto invoke builds manually, with the ability to override defined substitution variable values at\ninvocation time prior to running a build. You can also schedule manual\ntriggers to automatically run at a specific time.\n\nTo learn how to start builds manually using the gcloud CLI or\nthe Cloud Build API, see\n[Starting builds manually](/build/docs/running-builds/start-build-manually).\n\nBefore you begin\n\n-\n\n\n Enable the Cloud Build API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com&redirect=https://cloud.google.com/build/docs/automating-builds/create-manual-triggers)\n\n\u003c!-- --\u003e\n\n- Have your source code ready.\n\nManual triggers\n\nManual triggers enable you to set up builds that are only executed\nwhen you invoke your trigger on connected repositories. Let's say you're creating\na pipeline for deploying your source code to a staging or production environment.\nYou might want to automate your workflow, but are only looking to execute builds\nmanually. You can define manual triggers to do so.\n\nManual triggers enable you to manually invoke builds by:\n\n- Fetching source code from a hosted repository with a specified branch or tag.\n- Parametizing your build with substitutions that don't need to be passed in manually each time you execute a build.\n- Overriding defined substitution variable values at invocation time prior to invoking a build.\n\nIf you want to execute builds from your local working directory instead of a hosted repository\nor want to submit builds without creating a trigger, you can run the following\n`gcloud` command in your working directory: \n\n gcloud builds submit --config \u003cvar translate=\"no\"\u003eBUILD_CONFIG\u003c/var\u003e \u003cvar translate=\"no\"\u003eSOURCE_CODE\u003c/var\u003e\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003eBUILD_CONFIG\u003c/var\u003e is the path to the build config file.\n- \u003cvar translate=\"no\"\u003eSOURCE_CODE\u003c/var\u003e is the path or URL source code.\n\nTo learn more about how to use the `gcloud` command to start builds manually\nin your local directory, see [Starting builds manually](/build/docs/running-builds/start-build-manually).\n\nCreating manual triggers \n\nConsole\n\nTo create a manual trigger:\n\n1. Open the **Triggers** page:\n\n [Open the Triggers page](https://console.cloud.google.com/cloud-build/triggers)\n2. Select your project from the top of the page and click **Open**.\n\n3. Click **Create trigger**.\n\n4. Enter the following trigger settings:\n\n - **Name**: A name for your trigger.\n - **Region** : Select the [region](/build/docs/locations) for your trigger.\n\n - If you select **global** as the region, Cloud Build uses the default pool to run your build.\n - If you select a non-global region and the build config file associated with the trigger specifies a [private pool](/build/docs/private-pools/private-pools-overview), Cloud Build uses the private pool to run your build. In this case, the region you specify in your trigger must match the region where you created your private pool.\n - If you select a non-global region and the build config file associated with the trigger does **not** specify a private pool, Cloud Build uses the default pool to run your build in the same region as your trigger.\n - **Description** (Optional): A description for your trigger.\n\n - **Event** : Select **Manual invocation** to set up your trigger so that builds\n only run when the trigger is manually invoked.\n\n - **Source** : Select the repository to build when the manual trigger runs. You can\n specify **1st generation** or **2nd generation** as your source.\n\n | **Note:** The region of your repository must match the region of your trigger. If your source is in Cloud Source Repositories, your repository is not connected to a particular region, but to your project.\n | **Caution:** Effective June 17, 2024, Cloud Source Repositories isn't available\n | to new customers. If your organization hasn't\n | previously used Cloud Source Repositories, you can't enable the API or use\n | Cloud Source Repositories. New projects not connected to an organization can't enable the\n | Cloud Source Repositories API. Organizations that have used Cloud Source Repositories prior to\n | June 17, 2024 are not affected by this change.\n - **Revision**: Select the branch or tag to build when the manual trigger\n runs.\n\n - **Branch**: Set a trigger to build on this branch.\n You must specify a literal value. Regular expressions are not currently\n supported.\n\n - **Tag**: Set a trigger to build on this tag. You must specify a literal\n value. Regular expressions are not currently supported.\n\n - **Configuration**: Select the build config file located in\n your remote repository or create an inline build config file to\n use for your build.\n\n - **Type** : Select the type of configuration to use for your build.\n - **Cloud Build configuration file (yaml or json)**: Use a build config file for your configuration.\n - **Dockerfile** : Use a `Dockerfile` for your configuration.\n - **Location**: Specify the location for your configuration.\n\n - **Repository** : If your config file is located in your remote repository, provide the location of your [build config file](/build/docs/build-config), the `Dockerfile` directory, or the buildpacks directory. If your build config type is a `Dockerfile` or a buildpack, you will need to provide a name for the resulting image and optionally, a timeout for your build. When you've provided the `Dockerfile` or buildpack image name, you'll see a preview of the `docker build` or `pack` command that your build will execute.\n - **Inline** : If you selected **Cloud Build configuration file (yaml or json)** as your configuration option, you can specify your build config inline. Click **Open Editor** to write your build config file in the Google Cloud console using YAML or JSON syntax. Click **Done** to save your build config.\n\n | **Note:** Inline build configuration support is not available for `Dockerfile`.\n5. Click **Create** to create your manual trigger.\n\ngcloud\n\nFor a complete list of flags, see the [`gcloud` reference for how to create manual triggers](/../sdk/gcloud/reference/alpha/builds/triggers/create/manual).\n\nRunning manual triggers \n\nConsole\n\nTo run a manual trigger using Google Cloud console:\n\n1. Open the **Triggers** page in the Google Cloud console.\n\n [Open the triggers page](https://console.cloud.google.com/cloud-build/triggers)\n2. Locate your trigger in the list.\n\n3. Click **Run trigger**.\n\n After clicking **Run trigger** , you will see the **Run trigger** window pane\n on the right side. If you specified fields such as a branch name, tag\n name, or substitution variables, you will be able to override these fields\n at invocation time.\n | **Note:** You cannot specify any new fields or variables in this window pane. To do so, see instructions in the `gcloud` tab in this section.\n\n If you specified new variable values for your substitution, click **Run trigger**\n to execute your build.\n\n To run manual triggers on schedule, see\n [Scheduling builds](/build/docs/schedule-builds).\n\ngcloud\n\nTo run a manual trigger using the `gcloud` command-line tool, run the following\ncommand: \n\n gcloud builds triggers run \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eTRIGGER_NAME\u003c/span\u003e\u003c/var\u003e \\\n --region=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eREGION\u003c/span\u003e\u003c/var\u003e \\\n --branch=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eBRANCH_NAME\u003c/span\u003e\u003c/var\u003e \\\n --substitutions=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eSUBSTITUTION_VAR\u003c/span\u003e\u003c/var\u003e=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eSUBSTITUTION_VALUE\u003c/span\u003e\u003c/var\u003e\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003eTRIGGER_NAME\u003c/var\u003e is the name of your trigger.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is the [region](/build/docs/locations) for your trigger.\n- \u003cvar translate=\"no\"\u003eBRANCH_NAME\u003c/var\u003e is the name of your branch. You can also specify a tag using `--tag` or a commit ID using `--sha`.\n- \\[Optional\\]\u003cvar translate=\"no\"\u003eSUBSTITUTION_VAR\u003c/var\u003e is the variable name for your substitution value.\n- \\[Optional\\] \u003cvar translate=\"no\"\u003eSUBSTITUTION_VALUE\u003c/var\u003e is the value associated with your substitution variable.\n\nTo run manual triggers on schedule, see [Scheduling builds](/build/docs/schedule-builds).\n\nNext steps\n\n- Learn how to [start builds manually](/build/docs/running-builds/start-build-manually) using `gcloud` commands or the Cloud Build API.\n- Learn how to [schedule builds](/build/docs/automating-builds/schedule-builds).\n- Learn how to [create and manage triggers](/build/docs/automating-builds/create-manage-triggers).\n- Learn how to [view build results](/build/docs/view-build-results).\n- Learn how to [troubleshoot build errors](/build/docs/troubleshooting)."]]