Search code examples
google-cloud-platformgoogle-cloud-pubsubgoogle-source-repositories

source repository does not work to publish messages on pub/sub


I've followed below link in order to integrate my repository to pubsub. https://cloud.google.com/source-repositories/docs/quickstart-adding-pubsub-notifications#before-you-begin

However, my repository does not work to publish pubsub messages. This is the description of my repository:

$ gcloud beta source repos describe test
name: projects/[my-project-id]/repos/test
pubsubConfigs:
  projects/[my-project-id]/topics/test:
    messageFormat: JSON
    serviceAccountEmail: xxx-compute@developer.gserviceaccount.com
    topic: projects/[my-project-id]/topics/test
size: '2425'
url: https://source.developers.google.com/p/[my-project-id]/r/test

The topic 'test' has a subscription named 'test-subscription'.

$ gcloud pubsub subscriptions describe test-subscription
ackDeadlineSeconds: 10
expirationPolicy:
  ttl: 2678400s
messageRetentionDuration: 604800s
name: projects/[my-project-id]/subscriptions/test-subscription
pushConfig: {}
topic: projects/[my-project-id]/topics/test

So I tried to pull messages after pushing new changes. But, there is no messages from source repository. What's the problem with me? What can I do more? Please help me.


Solution

  • I replicated your scenario and it worked for me, it could have been a transient issue. When you followed it, it appeared to be in Beta state.

    This was the tutorial I followed, although, the only difference was that I used the gcloud commands without the "beta" argument:

    i.e.

    gcloud source repos update hello-world --add-topic=csr-test
    

    Instead of

    gcloud beta source repos update hello-world --add-topic=csr-test
    

    Here is a reference for the PubSubConfig Rest API