如何在BuildBot中使用GitHubCommentPush¶

时间:2019-07-18 10:23:12

标签: python github github-api buildbot

我正在尝试使用GitHubCommentPush将BuildBot的自动反馈添加到github pull请求中

但是我经常出错:

2019-07-18 09: 04: 56 + 0000 [-] Timing out client: IPv4Address (type = 'TCP', host = '86 .57.157.184 ', port = 42090)
2019-07-18 09: 04: 56 + 0000 [-] Timing out client: IPv4Address (type = 'TCP', host = '86 .57.245.94 ', port = 42086)
2019-07-18 09: 04: 56 + 0000 [-] Timing out client: IPv4Address (type = 'TCP', host = '86 .57.157.184 ', port = 42092)
2019-07-18 09: 04: 56 + 0000 [-] while invoking <bound method HttpStatusPushBase.buildStarted of <buildbot.reporters.github.GitHubCommentPush object at 0x7f4ae512aa20 >>
        Traceback (most recent call last):
          File "/home/andrei/bot/sandbox/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
            result = g.send (result)
          File "/home/andrei/bot/sandbox/lib/python3.6/site-packages/buildbot/reporters/http.py", line 80, in getMoreInfoAndSend
            yield self.send (build)
          File "/home/andrei/bot/sandbox/lib/python3.6/site-packages/twisted/internet/defer.py", line 1613, in unwindGenerator
            return _cancellableInlineCallbacks (gen)
          File "/home/andrei/bot/sandbox/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
            _inlineCallbacks (None, g, status)
        --- <exception caught here> ---
          File "/home/andrei/bot/sandbox/lib/python3.6/site-packages/buildbot/reporters/http.py", line 80, in getMoreInfoAndSend
            yield self.send (build)
          File "/home/andrei/bot/sandbox/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
            result = g.send (result)
          File "/home/andrei/bot/sandbox/lib/python3.6/site-packages/buildbot/reporters/github.py", line 177, in send
            content = yield response.content ()
        builtins.UnboundLocalError: local variable 'response' referenced before assignment

显然我的GitHub令牌无效。

我不知道buildbot需要什么样的令牌。

  • 我尝试创建OAuth应用程序(但未在GitHub Marketplace中发布),并将创建的应用程序的“客户端机密”用作令牌。

  • 我尝试以与上述相同的方式创建GitHub Apps,我使用Client Secret作为令牌。

  • 我试图创建个人访问令牌。

以上几点对我都没有帮助。

任何人都可以解释这应该如何工作吗?

这是我如何连接服务的代码。

        self.masterConf ['services'] = []
        self.masterConf ['secretsProviders'] = [
            secrets.SecretInAFile (dirname = "/ path / to / buildBotSecret")
        ]

        gc = reporters.GitHubCommentPush (token = util.Secret ("gitHub"),
                                         startDescription = 'Build started.',
                                         endDescription = 'Build done.')

        self.masterConf ['services']. append (gc)

2 个答案:

答案 0 :(得分:1)

根据代码,该错误表示我们在创建响应变量之前遇到了异常。

此代码中的错误管理非常糟糕。 所以我要做的就是在之前编辑该行

            content = yield response.content()

首先打印异常详细信息。

答案 1 :(得分:1)

它是buildBot 2.3.1版的错误。

修复了PR