Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara mengonfigurasi perlindungan cabang untuk repositori Secure Source Manager.
Perlindungan cabang memungkinkan administrator repositori menetapkan aturan untuk mengontrol siapa yang dapat membuat perubahan pada cabang, siapa yang perlu menyetujui atau meninjau perubahan, dan kondisi apa yang harus dipenuhi sebelum perubahan yang disetujui dapat digabungkan ke cabang.
Untuk mendapatkan izin yang diperlukan untuk mengonfigurasi aturan perlindungan cabang untuk repositori Secure Source Manager, minta administrator Anda untuk memberi Anda peran IAM berikut:
Untuk membuat aturan perlindungan cabang baru, lakukan hal berikut:
Di antarmuka web Secure Source Manager, pilih repositori yang ingin Anda lindungi dengan aturan perlindungan cabang.
Dari halaman repositori, klik Setelan.
Klik tab Aturan percabangan.
Klik Tambahkan aturan cabang.
Di kolom Branch rule ID, masukkan nama untuk aturan cabang.
ID aturan cabang hanya boleh berisi huruf kecil, angka, dan tanda hubung. Karakter pertama harus berupa huruf, dan karakter terakhir harus berupa huruf atau angka. ID aturan cabang memiliki maksimum 63 karakter.
Di kolom Filter cabang, masukkan nama cabang yang ingin Anda terapkan aturan, atau jika Anda ingin aturan diterapkan ke semua cabang, masukkan .*. Pencocokan ekspresi reguler penuh tidak didukung.
Filter aturan cabang yang diaktifkan harus unik untuk repositorinya. Pengguna dapat memiliki beberapa filter aturan cabang yang dinonaktifkan. Misalnya, Anda tidak dapat memiliki dua
aturan cabang yang diaktifkan dalam satu repositori dengan filter cabang main.
Jika beberapa aturan berlaku untuk cabang, aturan cabang dengan
nama cabang tertentu sebagai filter cabang akan menggantikan aturan karakter pengganti.
Misalnya, aturan cabang dengan filter cabang main akan menggantikan
aturan cabang dengan filter cabang .*. Aturan tidak digabungkan.
Di bagian Branch protection rule details, tentukan
persyaratan untuk aturan cabang Anda dari opsi berikut:
Mewajibkan permintaan pull sebelum menggabungkan: jika diaktifkan, commit
langsung ke cabang akan diblokir. Permintaan pull harus dibuka
sebelum digabungkan ke cabang yang dilindungi.
Jumlah peninjau yang diperlukan: tentukan jumlah peninjau yang diperlukan untuk menyetujui penggabungan permintaan pull.
Jumlah pemberi persetujuan yang diperlukan: tentukan jumlah
pemberi persetujuan yang diperlukan untuk menyetujui agar dapat menggabungkan pull request.
Peninjau dan pemberi persetujuan adalah pengguna dengan peran IAM
tertentu. Untuk mempelajari peran yang diperlukan bagi peninjau dan pemberi persetujuan, lihat Ringkasan perlindungan cabang.
Blokir penggabungan pada peninjauan dan persetujuan yang tidak berlaku: jika diaktifkan, peninjauan
atau persetujuan akan dihapus jika commit baru di-push ke pull request
setelah peninjauan atau persetujuan diberikan.
Wajibkan penyelesaian percakapan sebelum menggabungkan: jika diaktifkan, semua komentar kode dan peninjauan permintaan perubahan harus diselesaikan sebelum penggabungan.
Mewajibkan histori linear: jika diaktifkan, permintaan pull yang akan membuat histori Git non-linear tidak dapat digabungkan.
Wajibkan pemeriksaan status: jika diaktifkan, pemeriksaan status build yang dipilih harus berhasil sebelum permintaan pull dapat digabungkan. Anda harus
mengonfigurasi pemicu dalam file pemicu sebelum
dapat memilihnya sebagai pemeriksaan status untuk perlindungan cabang.
Untuk menyimpan aturan cabang, klik Kirim.
Tab Aturan cabang akan ditampilkan, dengan aturan cabang baru Anda tercantum.
Mengubah aturan perlindungan cabang
Untuk mengubah aturan perlindungan cabang, lakukan hal berikut:
Di antarmuka web Secure Source Manager, pilih repositori dengan aturan perlindungan cabang yang ingin Anda ubah.
Dari halaman repositori, klik Setelan.
Klik tab Aturan percabangan.
Klik nama aturan cabang yang ingin Anda ubah.
Edit aturan perlindungan cabang.
Klik Perbarui.
Aturan perlindungan cabang diperbarui.
Menghapus aturan perlindungan cabang
Untuk menghapus aturan perlindungan cabang, lakukan langkah-langkah berikut:
Di antarmuka web Secure Source Manager, pilih repositori yang ingin Anda hapus aturan cabangnya.
Dari halaman repositori, klik Setelan.
Klik tab Aturan percabangan.
Di baris aturan yang ingin Anda hapus, klik ikon Hapus.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[],[],null,["# Configure branch protection\n\nThis page explains how to configure branch protection for\nSecure Source Manager repositories.\n\nBranch protection lets repository administrators set rules to control who can\nmake changes to branches, who needs to approve or review changes, and what\nconditions must be met before an approved change can be merged into a branch.\n\nFor more information about branch protection rules, see [Branch protection\noverview](/secure-source-manager/docs/branch-protection-overview).\n\nBefore you begin\n----------------\n\n1. [Create a Secure Source Manager instance](/secure-source-manager/docs/create-instance).\n2. [Create a Secure Source Manager repository](/secure-source-manager/docs/create-repository).\n\n### Required roles\n\n\nTo get the permissions that\nyou need to configure branch protection rules for a Secure Source Manager repository,\n\nask your administrator to grant you the\nfollowing IAM roles:\n\n- [Secure Source Manager Instance Accessor](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.instanceAccessor) (`roles/securesourcemanager.instanceAccessor`) on the Secure Source Manager instance\n- [Secure Source Manager Repository Admin](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.repoAdmin) (`roles/securesourcemanager.repoAdmin`) on the Secure Source Manager repository\n- To approve pull requests on protected branches in any repository in a Secure Source Manager instance:\n - [Secure Source Manager Repository Pull Request Approver](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.repoPullRequestApprover) (`roles/securesourcemanager.repoPullRequestApprover`) on the Google Cloud project for the instance\n - [Secure Source Manager Repository Writer](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.repoWriter) (`roles/securesourcemanager.repoWriter`) on the Google Cloud project for the instance\n- To approve pull requests on protected branches in a single repository:\n - [Secure Source Manager Repository Pull Request Approver](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.repoPullRequestApprover) (`roles/securesourcemanager.repoPullRequestApprover`) on the repository\n - [Secure Source Manager Repository Writer](/iam/docs/roles-permissions/securesourcemanager#securesourcemanager.repoWriter) (`roles/securesourcemanager.repoWriter`) on the repository\n\n \u003cbr /\u003e\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\nFor information on granting Secure Source Manager roles,\nsee [Access control with IAM](/secure-source-manager/docs/access-control) and\n[Grant users instance access](/secure-source-manager/docs/grant-users-instance-access).\n\nCreate a branch protection rule\n-------------------------------\n\nTo create a new branch protection rule, do the following:\n\n1. In the Secure Source Manager web interface, select the repository you want to protect with a branch protection rule.\n2. From the repository page, click **Settings**.\n3. Click the **Branch rule** tab.\n4. Click **Add branch rule**.\n5. In the **Branch rule ID** field, enter a name for the branch rule.\n\n Branch rule IDs are restricted to lower-case letters, numbers,\n and hyphens. The first character must be a letter, and the last character\n must be a letter or a number. Branch rule IDs have a 63 character\n maximum.\n6. In the **Branch filter** field, enter the name of the branch you want\n the rule to apply to, or if you want the rule to apply to all branches,\n enter `.*`. Full regular expression matching is not supported.\n\n Enabled branch rule filters must be unique to their repository. Users can\n have multiple disabled branch rule filters. For example, you can't have two\n enabled branch rules in a single repository with the branch filter `main`.\n\n When multiple rules are applicable for a branch, the branch rule with a\n specific branch name as the branch filter will override the wildcard rule.\n For example, a branch rule with branch filter `main` will override a\n branch rule with the branch filter `.*`. Rules are not combined.\n7. In the **Branch protection rule details** section, specify the\n requirements for your branch rule from the following options:\n\n - **Require a pull request before merging**: if enabled, direct\n commits to the branch will be blocked. A pull request must be opened\n before merging into the protected branch.\n\n | **Note:** You can't apply this rule to all branches using `.*`, because that would prevent pushing directly to all branches, even new branches.\n - **Required number of reviewers**: specify the number of\n reviewers required to approve in order to merge the pull request.\n\n - **Required number of approvers**: specify the number of\n approvers required to approve in order to merge the pull request.\n\n Reviewers and approvers are users with specific IAM\n roles. To learn which roles are required for reviewers and approvers,\n see [Branch protection overview](/secure-source-manager/docs/branch-protection-overview).\n - **Block merge on stale reviews and approvals**: if enabled, a review\n or approval is removed if new commits are pushed to the pull request\n after the review or approval is granted.\n\n - **Require conversation resolution before merging**: if enabled,\n all code comments and request change reviews must be resolved before\n merging.\n\n - **Require linear history**: if enabled, pull requests that would create\n a non-linear Git history can't be merged.\n\n - **Require status checks** : if enabled, the selected build status checks\n must be successful before a pull request can be merged. You must\n configure triggers in your [triggers file](/secure-source-manager/docs/triggers-file-schema) before\n you can select them as status checks for branch protection.\n\n8. To save the branch rule, click **Submit**.\n\nThe Branch rules tab is displayed, with your new branch rule listed.\n\nModify a branch protection rule\n-------------------------------\n\nTo modify a branch protection rule, do the following:\n\n1. In the Secure Source Manager web interface, select the repository with the branch protection rule you want to modify.\n2. From the repository page, click **Settings**.\n3. Click the **Branch rules** tab.\n4. Click the name of the branch rule you want to modify.\n5. Edit the branch protection rule.\n6. Click **Update**.\n\nThe branch protection rule is updated.\n\nDelete a branch protection rule\n-------------------------------\n\nTo delete a branch protection rule, do the following:\n\n1. In the Secure Source Manager web interface, select the repository that you want to remove the branch rule from.\n2. From the repository page, click **Settings.**\n3. Click the **Branch rule** tab.\n4. In the row of the rule you want to delete, click the **Delete** icon.\n5. In the **Remove branch rule** confirmation screen, click **Yes**.\n\nThe branch protection rule is deleted.\n\nWhat's next\n-----------\n\n- Read the [Branch protection overview](/secure-source-manager/docs/branch-protection-overview).\n- Learn how to automate builds by following the steps in [Connect to Cloud Build](/secure-source-manager/docs/connect-cloud-build).\n- Learn how to [check the status of automated builds](/secure-source-manager/docs/create-triggers-file#build-status)."]]