예제 #1
0
    def notifyTester(self, who, host_url, project_url, branch_name):
        botGerrit = BotGerrit()
        botJira = BotJira()
        today = datetime.date.today()
        yesterday = today - datetime.timedelta(days=1)
        # botPatchs = botGerrit.get_patch_info_from_file(yesterday)
        botPatchs = botGerrit.get_patch_info_from_project(host_url=host_url,
                                                          project_url=project_url,
                                                          branch_name=branch_name,
                                                          status='merged',
                                                          yesterday=yesterday,
                                                          today=today)
        if (len(botPatchs) > 0):
            message = "%s GameDock模块合入%s分支问题数 = %d \n" \
                      "👇 👇 👇 👇 👇 👇 👇 👇 👇 👇 👇 👇 👇 👇 \n" % (yesterday, branch_name, len(botPatchs))

            for botPatch in botPatchs:
                botIssue = botJira.searchIssue(botPatch.issue)
                message += review_message.format(issue=botPatch.issue,
                                                 issue_link=botPatch.issue_link,
                                                 owner=botPatch.owner_name,
                                                 patch_link=botPatch.url,
                                                 title=botIssue.title)

            print(datetime.datetime.now())
            print(message)

            if self.isRaspberryPi:
                ding = DingDing(self.access_token)
                ding.set_secret(self.secret)
                ding.send_text(message)
            else:
                bot = Bot(who)
                bot.set_text(message, type='text').send()
예제 #2
0
 def fetchIssues(self, sql):
     botJira = BotJira()
     botIssues = botJira.searchJql(sql)
     return botIssues
예제 #3
0
파일: BotDI.py 프로젝트: journeyOS/JiraBot
 def fetchIssues(self, sql):
     botJira = BotJira()
     botIssues = botJira.searchJql(sql)
     print(datetime.datetime.now())
     print('共 %d 个问题待解决' % len(botIssues))
     return botIssues
예제 #4
0
    def fetchGameDockPatchMessage(self, who):
        botGerrit = BotGerrit()
        botJira = BotJira()

        botPatchs = botGerrit.get_comment_patch_info_from_project(
            host_url=self.host_url_prv,
            project_url=self.project_url_game_dock,
            status='open',
            comment='need_review')
        for botPatch in botPatchs:
            flags = False
            result = self.tableIssue.find_one(issue=botPatch.number)
            print(datetime.datetime.now())
            if result is not None:
                if result["dock_team"] == 1:
                    print("dock team %s has been saved\n" % (botPatch.number))
                else:
                    flags = True
                    self.tableIssue.update(
                        dict(issue=botPatch.number,
                             dock_team=1,
                             game_team=result["game_team"]), ["issue"])
                    print("dock team %s need save(update)\n" %
                          (botPatch.number))
            else:
                flags = True
                self.tableIssue.insert(
                    dict(issue=botPatch.number, dock_team=1, game_team=0))
                print("dock team %s need save\n" % (botPatch.number))

            if (flags):
                if self.isRaspberryPi:
                    message_format = review_message_pi
                else:
                    message_format = review_message

                issue = "Patch未填单号"
                link = "botPatch.url"

                if botPatch.issue != "null":
                    botIssue = botJira.searchIssue(botPatch.issue)
                    if botIssue is not None:
                        issue = botIssue.issue
                        link = botIssue.link

                message = message_format.format(issue, link,
                                                botPatch.owner_name,
                                                botPatch.url,
                                                botPatch.commitMessage)
                print(message)
                if self.isRaspberryPi:
                    ding = DingDing(self.access_token)
                    ding.set_secret(self.secret)
                    ding.send_markdown('Code review', message)
                else:
                    if who == "":
                        who = self.bot_key_test
                    bot = Bot(who)
                    bot.set_text(message, type='markdown').send()
                    bot.set_text('',
                                 type='text').set_mentioned_list(["@all"
                                                                  ]).send()