Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cloud Build vous permet de configurer des déclencheurs qui n'exécutent pas immédiatement de compilation, mais marquent une compilation comme en attente jusqu'à ce qu'elle soit approuvée. Si un utilisateur disposant d'autorisations approuve une compilation en attente, celle-ci démarre. Si l'approbation est refusée, la compilation ne démarrera pas.
Cette page explique comment approuver ou rejeter manuellement des compilations.
Pour savoir comment configurer un déclencheur qui nécessite une approbation, consultez la page Créer un déclencheur de compilation.
Si un utilisateur dispose du rôle Éditeur Cloud Build, il est autorisé à mettre à jour un déclencheur pour exiger ou non une approbation. Pour en savoir plus sur les autorisations Cloud Build, consultez la page IAM et autorisations. Pour autoriser un utilisateur à approuver des compilations dans votre projet, il doit disposer du rôle Validateur Cloud Build.
Pour ajouter le rôle Validateur Cloud Build, procédez comme suit:
Dans la section Ajouter des comptes principaux, ajoutez des utilisateurs pour leur accorder les autorisations qui leur permettent d'autoriser les compilations en attente dans votre projet.
Vous devez ajouter un ou plusieurs comptes principaux dans cette section. Si vous vous ajoutez en tant que compte principal, notez que vous devrez toujours approuver manuellement une compilation en attente si votre déclencheur est contrôlé par une approbation.
Dans la section Attribuer des rôles, sélectionnez Cloud Build > Validateur Cloud Build.
Les utilisateurs que vous avez spécifiés peuvent désormais approuver ou rejeter les compilations en attente.
Approuver des compilations
Console
Pour approuver une compilation en attente dans la console Google Cloud :
Ouvrez la page Tableau de bord Cloud Build dans la console Google Cloud .
Si des compilations sont en attente d'approbation, un message s'affiche en haut de la page avec le nombre de compilations en attente d'approbation. À droite du message, cliquez sur Afficher les compilations pour afficher la liste des compilations en attente d'approbation.
Cochez les cases des compilations que vous souhaitez approuver.
Vous pouvez sélectionner plusieurs compilations à approuver ou une compilation individuelle à approuver.
En haut de la page, cliquez sur Approuver pour valider les compilations sélectionnées.
Avant le début de la compilation, la boîte de dialogue Approuver la compilation s'affiche.
Dans la boîte de dialogue, vous pouvez ajouter un message facultatif et une URL à afficher avec l'approbation de la compilation. Pour inclure une URL, cliquez sur Afficher des options supplémentaires pour saisir une URL.
Dans la boîte de dialogue, cliquez sur Approve (Approuver) pour approuver la compilation.
Une fois la compilation approuvée, la compilation démarre immédiatement. Si la règle d'administration de l'organisation (constraints/cloudbuild.allowedIntegrations) refuse l'accès au dépôt connecté, elle remplacera l'approbation. Pour en savoir plus, consultez Gater les builds en fonction des règles d'administration.
gcloud
Pour approuver une compilation en attente à l'aide de gcloud commands, exécutez la commande suivante dans la fenêtre de votre terminal:
Remplacez les valeurs d'espace réservé dans les commandes ci-dessus par les éléments suivants :
BUILD_ID est l'ID de la compilation que vous souhaitez approuver.
PROJECT_ID est l'ID de votre projet.
[Facultatif] URL est l'URL contenant des informations sur l'approbation, telles qu'un lien vers un ticket JIRA.
[Facultatif] COMMENT est le message que vous souhaitez afficher après l'approbation de la compilation.
Une fois la compilation approuvée, la compilation démarre immédiatement. Si la règle d'administration permettant de définir les compilations pour les intégrations autorisées (constraints/cloudbuild.allowedIntegrations) est définie, elle remplacera l'approbation. Pour en savoir plus, consultez Appliquer le règlement de l'organisation aux déclencheurs de compilation.
Refuser les compilations
Console
Pour rejeter une compilation en attente dans la console Google Cloud :
Ouvrez la page Tableau de bord Cloud Build dans la console Google Cloud .
Si des compilations sont en attente d'approbation, un message s'affiche en haut de la page avec le nombre de compilations en attente d'approbation. À droite du message, cliquez sur Afficher les compilations pour afficher la liste des compilations en attente d'approbation.
Vous pouvez sélectionner plusieurs compilations à rejeter ou une compilation individuelle à rejeter. Cochez les cases correspondant aux compilations que vous souhaitez refuser.
Cliquez sur Refuser en haut de la page pour rejeter la compilation.
Si vous refusez une compilation, celle-ci ne démarre pas.
gcloud
Pour rejeter une compilation en attente à l'aide de gcloud commands, exécutez la commande suivante dans la fenêtre de votre terminal:
Remplacez les valeurs d'espace réservé dans les commandes ci-dessus par les éléments suivants :
BUILD_ID est l'ID de la compilation que vous souhaitez rejeter.
PROJECT_ID est l'ID de votre projet.
[Facultatif] URL est l'URL contenant des informations sur le refus, telles qu'un lien vers un ticket JIRA.
[Facultatif] COMMENT est le message que vous souhaitez afficher en cas de refus de la compilation.
Si vous refusez une compilation, celle-ci ne démarre jamais.
Recevoir des notifications pour les compilations en attente d'approbation
Vous pouvez utiliser les systèmes d'alerte Cloud Build pour recevoir des notifications sur les compilations en attente à l'aide du système d'alerte géré par Cloud Build, par exemple :Slack ou le serveur SMTP, ou en créant votre propre système d'alerte.
Pour configurer les notifications, procédez comme suit:
Suivez les instructions fournies sur l'une des pages suivantes pour configurer les notifications pour le service souhaité:
Lorsque vous configurez des notifications à l'aide de l'une des pages ci-dessus, vous devez configurer votre système d'alerte pour filtrer les compilations à l'état PENDING.
Vous recevrez des notifications concernant les compilations en attente d'approbation.
Dans l'exemple de fichier de configuration du système d'alerte SMTP suivant, le champ de filtre utilise le CEL (Common Expression Language) pour filtrer les événements de compilation à l'état PENDING:
Pour déployer votre système d'alerte, exécutez la commande gcloud run dans votre terminal.
L'exemple suivant déploie le système d'alerte SMTP à l'aide de Cloud Run.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/08 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/08 (UTC)."],[[["\u003cp\u003eCloud Build allows builds to be marked as pending, requiring manual approval before they start.\u003c/p\u003e\n"],["\u003cp\u003eUsers with the Cloud Build Approver role can approve or reject pending builds, either through the Google Cloud console or using gcloud commands.\u003c/p\u003e\n"],["\u003cp\u003eApproving a build initiates the build process immediately, while rejecting a build prevents it from ever starting.\u003c/p\u003e\n"],["\u003cp\u003eNotifications for pending builds can be configured through Cloud Build notifiers, allowing users to be alerted when builds are awaiting approval, and can be set up through services such as BigQuery, HTTP, Slack, SMTP and others.\u003c/p\u003e\n"],["\u003cp\u003eUsers will need to create a build trigger configured to require approval before they can approve or reject pending builds.\u003c/p\u003e\n"]]],[],null,["Cloud Build enables you to configure triggers that do not\nimmediately execute a build but instead mark a build as pending\nuntil approved. If a user with permissions approves a pending\nbuild, the build will start. If the approval is denied,\nthe build will not start.\n\nThis page explains how you can manually approve or reject builds.\nTo learn how to configure a trigger that requires approval, see [Creating a build trigger](/build/docs/automating-builds/create-manage-triggers#console).\n| **Note:** You can't approve or reject pending builds older than 2 months. For details, see [Troubleshooting](/build/docs/troubleshooting#pending_build).\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/approve-builds)\n\n\u003c!-- --\u003e\n\n- Install [Google Cloud CLI](/sdk/docs/install-sdk).\n\n | **Note:** If you've already installed gcloud CLI previously, make sure you have the latest available version by running `gcloud components update`.\n- If you have not already, [create a build trigger](/build/docs/automating-builds/create-manage-triggers#console) configured to require approval.\n\nGranting permissions\n\nIf a user has the **Cloud Build Editor role** , the user has\npermissions to update a trigger to require or not require approval. To learn more\nabout Cloud Build permissions, see [IAM and\npermissions](/build/docs/iam-roles-permissions). In order to grant\na user permission to approve builds within your project, the user\nmust have the **Cloud Build Approver** role.\n\nTo add the **Cloud Build Approver** role:\n\n1. Open the **IAM** page in the Google Cloud console.\n\n [Open the IAM page](https://console.cloud.google.com/iam-admin/iam)\n2. Click **Grant access**.\n\n You will see the **Grant access** panel.\n3. In the **Add principals** section, add users to give them permission to\n grant approval for pending builds within your project.\n\n You *must* add one or more principals in this section. If you add yourself as\n a principal, note that you will still need to manually approve a pending\n build if your trigger is gated by an approval.\n4. In the **Assign roles** section, select **Cloud Build** \\\u003e **Cloud Build Approver**.\n\nThe users you specified now have access to approve or reject pending builds.\n\nApproving builds \n\nConsole\n\nTo approve a pending build in the Google Cloud console:\n\n1. Open the **Cloud Build Dashboard** page in the Google Cloud console.\n\n [Open the Cloud Build Dashboard page](https://console.cloud.google.com/cloud-build/dashboard)\n2. If you have builds to approve, you will see a message at the top of the page\n with the number of builds awaiting your approval. To the right of the message,\n click **View Builds** to view the list of builds awaiting your approval.\n\n3. Click on the checkboxes of the builds you'd like to approve.\n You can select multiple builds to approve or one individual build to\n approve.\n\n4. At the top of the page, click **Approve** to approve your selected builds.\n\n5. Before the build starts, you will see the **Approve build** dialog box.\n In the dialog box, you can add an optional message and a URL to be\n displayed along with the build's approval. To include a URL, click\n **Show additional options** to enter a URL.\n\n6. In the dialog box, click **Approve** to approve the build.\n\nOnce you approve, the build will start immediately. If the organization\npolicy\n(`constraints/cloudbuild.allowedIntegrations`) denies access to\nthe connected repository, the policy will\noverride the approval. To learn more, see [Gate builds on organization policy](/build/docs/securing-builds/gate-builds-organization-policy).\n\ngcloud\n\nTo approve a pending build using `gcloud commands`, run the following command\nin your terminal window: \n\n gcloud builds approve \u003cvar translate=\"no\"\u003eBUILD_ID\u003c/var\u003e \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --url=\u003cvar translate=\"no\"\u003eURL\u003c/var\u003e \\\n --comment=\u003cvar translate=\"no\"\u003eCOMMENT\u003c/var\u003e\n\nReplace the placeholder values in the above commands with the following:\n\n- \u003cvar translate=\"no\"\u003eBUILD_ID\u003c/var\u003e is the ID of the build you'd like to approve.\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is your project ID.\n- \\[Optional\\] \u003cvar translate=\"no\"\u003eURL\u003c/var\u003e is the URL containing information about the approval, such as a link to a JIRA ticket.\n- \\[Optional\\] \u003cvar translate=\"no\"\u003eCOMMENT\u003c/var\u003e is the message you want displayed upon approval of the build.\n\nOnce you approve, the build will start immediately. If the organization\npolicy to define builds for allowed integrations\n(`constraints/cloudbuild.allowedIntegrations`) is set, the policy will\noverride the approval. To learn more, see [Applying organization\npolicy to build triggers](/build/docs/securing-builds/apply-organization-policy-triggers).\n\nRejecting builds \n\nConsole\n\nTo reject a pending build in the Google Cloud console:\n\n1. Open the **Cloud Build Dashboard** page in the Google Cloud console.\n\n [Open the Cloud Build Dashboard page](https://console.cloud.google.com/cloud-build/dashboard)\n2. If you have builds to approve, you will see a message at the top of the page\n with the number of builds awaiting your approval. To the right of the message,\n click **View Builds** to view the list of builds awaiting your approval.\n\n3. You can select multiple builds to reject or one individual build to\n reject. Click on the checkboxes of the builds you'd like to reject.\n\n4. Click **Reject** at the top of the page to reject the build.\n\nIf you reject a build, the build will not start.\n\ngcloud\n\nTo reject a pending build using `gcloud commands`, run the following command\nin your terminal window: \n\n gcloud builds reject \u003cvar translate=\"no\"\u003eBUILD_ID\u003c/var\u003e \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --url=\u003cvar translate=\"no\"\u003eURL\u003c/var\u003e \\\n --comment=\u003cvar translate=\"no\"\u003eCOMMENT\u003c/var\u003e\n\nReplace the placeholder values in the above commands with the following:\n\n- \u003cvar translate=\"no\"\u003eBUILD_ID\u003c/var\u003e is the ID of the build you'd like to reject.\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is your project ID.\n- \\[Optional\\] \u003cvar translate=\"no\"\u003eURL\u003c/var\u003e is the URL containing information about the rejection, such as a link to a JIRA ticket.\n- \\[Optional\\] \u003cvar translate=\"no\"\u003eCOMMENT\u003c/var\u003e is the message you want displayed upon rejection of the build.\n\nIf you reject a build, the build will never start.\n\nReceiving notifications for builds waiting for approval\n\nYou can use Cloud Build notifiers to receive notifications about\npending builds using a Cloud Build maintained notifier,\nsuch as [Slack](/build/docs/configuring-notifications/configure-slack) or [SMTP](/build/docs/configuring-notifications/configure-smtp) server, or by\n[creating your own notifier](/build/docs/configuring-notifications/create-notifier).\n\nTo configure notifications:\n\n1. Follow the instructions on one of following pages to\n configure notifications for your desired service:\n\n - [BigQuery](/build/docs/configuring-notifications/configure-bigquery)\n - [HTTP](/build/docs/configuring-notifications/configure-http)\n - [Slack](/build/docs/configuring-notifications/configure-slack)\n - [SMTP](/build/docs/configuring-notifications/configure-smtp)\n - [Creating your own notifier](/build/docs/configuring-notifications/create-notifier)\n2. When configuring notifications using one of the pages above, you must\n configure your notifier to filter builds with a *PENDING* status.\n This will send you notifications on builds waiting for approval.\n In the following example SMTP notifier configuration file, the filter field\n uses [Common Expression Language](https://github.com/google/cel-spec) (CEL) to filter build events with a PENDING status:\n\n apiVersion: cloud-build-notifiers/v1\n kind: SMTPNotifier\n metadata:\n name: example-smtp-notifier\n spec:\n notification:\n filter: build.status == Build.Status.PENDING\n delivery:\n server: example.gmail.com\n port: 0000\n sender: sender@example.com\n ...\n\n To view the full example, see the [notifier configuration file for the SMTP notifier](https://github.com/GoogleCloudPlatform/cloud-build-notifiers/blob/master/smtp/smtp.yaml.example).\n3. To deploy your notifier, run the `gcloud run` command in your terminal.\n The following example deploys the SMTP notifier using Cloud Run.\n\n gcloud run deploy example.gmail.com \\\n --image=us-east1-docker.pkg.dev/gcb-release/cloud-build-notifiers/smtp:latest \\\n --update-env-vars=CONFIG_PATH=smtp.yaml, PROJECT_ID=my-project\n\nYou should now receive notifications for pending builds to your service.\n\nWhat's next\n\n- Learn how to [create and manage build triggers](/build/docs/automating-builds/create-manage-triggers).\n- Learn how to [view build results for build triggers](/build/docs/view-build-results#viewing_build_results_for_build_triggers)"]]