2024년 6월 17일부터 신규 고객은 Cloud Source Repositories를 사용할 수 없습니다. 이전에 조직에서 Cloud Source Repositories를 사용한 적이 없는 경우 API를 사용 설정할 수 없거나 Cloud Source Repositories를 사용할 수 없습니다. 조직에 연결되지 않은 새 프로젝트는 Cloud Source Repositories API를 사용 설정할 수 없습니다. 2024년 6월 17일 이전에 Cloud Source Repositories를 사용한 조직은 이 변경사항의 영향을 받지 않습니다.
Pub/Sub를 사용하면 Google Cloud 저장소에 대한 변경사항 알림을 수신할 수 있습니다. 이러한 알림은 사용자가 새 저장소를 만들거나, 저장소를 삭제하거나, 기존 저장소에 변경사항을 푸시할 때 이를 알립니다. 특정 저장소 또는 전체 Google Cloud 프로젝트에 대한 알림을 구성할 수 있습니다.
주제와 구독을 만들 수 있는 적절한 권한이 있는지 확인합니다. 자세한 내용은 액세스 제어를 참조하세요.
주제에 게시할 수 있는 서비스 계정이 있는지 확인합니다. 기본적으로 Cloud Source Repositories는 Compute Engine 기본 서비스 계정을 사용하여 메시지를 게시합니다. 자세한 내용은 Cloud Source Repositories용 Pub/Sub 알림을 참조하세요.
Pub/Sub 주제 만들기
알림을 받으려는 각 Cloud Source Repositories 프로젝트 또는 저장소에 대해 Pub/Sub 주제를 만들어야 합니다. Google Cloud Console 또는 gcloud 명령줄 도구를 사용하여 주제를 만들 수 있습니다.
주제를 만들 때 저장소의 정규화된 URI를 사용해야 합니다.
정규화된 URI는 다음과 같습니다.
[SERVICE_ACCOUNT_NAME]은 Cloud Build 서비스 계정의 이름입니다.
서비스 계정은 저장소와 동일한 프로젝트에 있어야 하며 pubsub.topics.publish 권한이 있어야 지정된 주제에 대한 메시지를 게시할 수 있습니다. 서비스 계정에는 iam.serviceAccounts.actAs 권한이 있어야 합니다. 서비스 계정을 지정하지 않으면 기본적으로 Compute Engine 기본 서비스 계정이 사용됩니다.
주제 삭제
Google Cloud CLI를 사용하여 프로젝트 또는 저장소와 Pub/Sub 주제 간 연결을 삭제할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-21(UTC)"],[],[],null,["# Configuring Pub/Sub notifications\n\nYou can receive notifications of changes to your Google Cloud\nrepositories by using Pub/Sub. These\nnotifications inform you when a user creates a new repository, deletes a\nrepository, or pushes a change to an existing repository. You can choose to\nconfigure notifications for specific repositories or across an entire\nGoogle Cloud project.\n\nTo learn more about Pub/Sub, see\n[What is Pub/Sub?](/pubsub/docs/overview)\n\nBefore you begin\n----------------\n\n- If you haven't already done so, [create a repository](/source-repositories/docs/creating-an-empty-repository).\n- Verify that you have the appropriate permissions to create topics and subscriptions. For more information, see [Access control](/source-repositories/docs/configure-access-control).\n- Ensure you have a service account that can publish to your topic. By default, Cloud Source Repositories uses the Compute Engine default service account to publish messages. For more information, see [Pub/Sub notifications for Cloud Source Repositories](/source-repositories/docs/pubsub-notifications).\n\nCreate a Pub/Sub topic\n----------------------\n\nFor each Cloud Source Repositories project or repository for which you'd like\nnotifications, you need to create a Pub/Sub topic. You can create\na topic using either the Google Cloud console or the `gcloud` command-line\ntool.\n\nWhen you create a topic, you need to use a qualified URI for your repository.\nThe qualified URI is: \n\n projects/[PROJECT_ID]/topics/[TOPIC_NAME]\n\nWhere:\n\n- `[PROJECT_ID]` is your Google Cloud project ID.\n- `[TOPIC_NAME]` is the name of the topic.\n\nTo create a topic, follow these steps. \n\n### Console\n\n1. In the Google Cloud console, go to the Pub/Sub **Topics**\n page.\n\n [Go to the Topics page](https://console.cloud.google.com/cloudpubsub/topicList)\n2. Click **Create Topic**.\n\n3. Enter a topic name with the URI:\n\n projects/[PROJECT_ID]/topics/[TOPIC_NAME]\n\n Where:\n - `[PROJECT_ID]` is your Google Cloud project ID.\n - `[TOPIC_NAME]` is the name of the topic.\n4. Click **Create**.\n\n The **Topic details** page opens.\n\n### gcloud\n\nIn a terminal window, run the following command: \n\n gcloud pubsub topics create projects/[PROJECT_ID]/topics/[TOPIC_NAME]\n\nWhere:\n\n- `[PROJECT_ID]` is your Google Cloud project ID.\n- `[TOPIC_NAME]` is the name of the topic.\n\n| **Note:** If this command returns a `Resource already exists in the project` error, you might already have a Cloud Source Repositories topic.\n\nTo learn more about the `gcloud pubsub topics` command, see the\n[`topics` documentation](/sdk/gcloud/reference/pubsub/topics).\n\nCreate a Pub/Sub subscription\n-----------------------------\n\nTo receive events published to a topic, you need to create a\n[Pub/Sub subscription](/pubsub/docs/subscriber#create).\n\nA [subscriber app](/pubsub/docs/subscriber)\nreceives messages from your repository's topic. Subscribers can respond to your\nrepository events by sending notifications or triggering a build.\n\nTo create a subscription, follow these steps. \n\n### Console\n\n1. In the Google Cloud console, go to the Pub/Sub **Topics**\n page.\n\n [Go to the Topics page](https://console.cloud.google.com/cloudpubsub/topicList)\n2. Click the name of your project's topic.\n\n3. Click **Create Subscription**.\n\n The **Add subscription to topic** page opens.\n4. Enter a subscription name:\n\n projects/[PROJECT_ID]/subscriptions/[SUBSCRIPTION_NAME]\n\n Where:\n - `[PROJECT_ID]` is your Google Cloud project ID.\n - `[SUBSCRIPTION_NAME]` is the name of the Pub/Sub subscription.\n5. Leave **Delivery type** set to **Pull**.\n\n6. Click **Create**.\n\n### gcloud\n\nIn a terminal window, run the following command: \n\n gcloud pubsub subscriptions create [SUBSCRIPTION_NAME] --topic=[TOPIC_NAME]\n\nWhere:\n\n- `[SUBSCRIPTION_NAME]` is the name of the Pub/Sub subscription.\n- `[TOPIC_NAME]` is the name of the topic.\n\n| **Note:** Use the optional flag `--ack-deadline` to configure how many seconds the system waits for acknowledgement from the subscriber before re- attempting delivery. Without this flag, the default deadline is 10 seconds.\n\nTo learn more about the `gcloud pubsub subscriptions` command, see the\n[`subscriptions` documentation](/sdk/gcloud/reference/pubsub/subscriptions).\n\nAdd a topic\n-----------\n\nYou can associate a Pub/Sub topic with a Google Cloud\nproject or repository by using the Google Cloud CLI.\n\nTo associate a topic with an entire project, enter the following command: \n\n gcloud source project-configs update --add-topic=[TOPIC_NAME] --service-account=[SERVICE_ACCOUNT_NAME]\n\nWhere:\n\n- `[TOPIC_NAME]` is the name of the Pub/Sub topic.\n- `[SERVICE_ACCOUNT_NAME]` is the name of your Cloud Build service account.\n\nTo associate a topic with a specific repository, enter the following command: \n\n gcloud source repos update [REPOSITORY_NAME] --add-topic=[TOPIC_NAME] --service-account=[SERVICE_ACCOUNT_NAME]\n\nWhere:\n\n- `[REPOSITORY_NAME]` is the name of your Google Cloud repository.\n- `[TOPIC_NAME]` is the name of the Pub/Sub topic.\n- `[SERVICE_ACCOUNT_NAME]` is the name of your Cloud Build service account.\n\nThe service account must be in the same project as the repository, and it\nmust have `pubsub.topics.publish` permission to publish a message on the\nspecified topic. You must have `iam.serviceAccounts.actAs` permission on the\nservice account. If the service account isn't specified, it defaults to the\nCompute Engine default service account.\n| **Note:** For information on how to delete a Pub/Sub topic, see [Managing topics and subscriptions](/pubsub/docs/admin#create_a_topic).\n\nRemove a topic\n--------------\n\nYou can remove an association between a project or repository and a\nPub/Sub topic by using the Google Cloud CLI.\n\nTo remove a topic from an entire project, enter the following command: \n\n gcloud source project-configs update --remove-topic=[TOPIC_NAME]\n\nTo remove a topic from a specific repository, enter the following command: \n\n gcloud source repos update [REPOSITORY_NAME] --remove-topic=[TOPIC_NAME]\n\n| **Note:** For information on how to delete a Pub/Sub topic, see [Managing topics and subscriptions](/pubsub/docs/admin#delete_a_topic).\n\nSet the topic format\n--------------------\n\nNotifications for Cloud Source Repositories can use either the JSON or Protocol\nBuffers format. To set the format for a topic, you can use the\n`--message-format` parameter when you add the topic: \n\n gcloud source project-configs update --add-topic=[TOPIC_NAME] --message-format=[json|protobuf]\n\nYou can also use the `set-format` command: \n\n gcloud source project-configs update --update-topic=[TOPIC_NAME] --message-format=[json|protobuf]\n\nWhat's next\n-----------\n\n- Learn more about [Pub/Sub notifications for Cloud Source Repositories](/source-repositories/docs/pubsub-notifications).\n- Read the [Pub/Sub documentation](/pubsub/docs).\n- For an in-depth explanation of Pub/Sub, see [What is Pub/Sub?](/pubsub/docs/overview).\n- Learn more about [Pub/Sub access control roles](/pubsub/docs/access_control#tbl_roles)."]]