|
|
@ -1,28 +1,29 @@
|
|
|
|
# Copyright (C) 2015 The Sipwise Team - http://sipwise.com
|
|
|
|
# Copyright (C) 2015-2020 The Sipwise Team - http://sipwise.com
|
|
|
|
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by the Free
|
|
|
|
# under the terms of the GNU General Public License as published by the Free
|
|
|
|
# Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
# Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
# any later version.
|
|
|
|
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
# more details.
|
|
|
|
# more details.
|
|
|
|
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
from django.db import models
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
from repoapi import utils
|
|
|
|
|
|
|
|
from release_dashboard.utils.build import is_ngcp_project
|
|
|
|
from release_dashboard.utils.build import is_ngcp_project
|
|
|
|
|
|
|
|
from repoapi import utils
|
|
|
|
|
|
|
|
from repoapi.conf import settings
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
workfront_re = re.compile(r"TT#(\d+)")
|
|
|
|
workfront_re = re.compile(r"TT#(\d+)")
|
|
|
|
workfront_re_branch = re.compile('^mr[0-9]+\.[0-9]+\.[0-9]+$')
|
|
|
|
workfront_re_branch = re.compile(r"^mr[0-9]+\.[0-9]+\.[0-9]+$")
|
|
|
|
commit_re = re.compile(r"^(\w{7}) ")
|
|
|
|
commit_re = re.compile(r"^(\w{7}) ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -62,8 +63,9 @@ class WorkfrontNoteInfo(models.Model):
|
|
|
|
|
|
|
|
|
|
|
|
def workfront_release_target(instance, wid):
|
|
|
|
def workfront_release_target(instance, wid):
|
|
|
|
if not is_ngcp_project(instance.projectname):
|
|
|
|
if not is_ngcp_project(instance.projectname):
|
|
|
|
logger.info("%s not a NGCP project, skip release_target",
|
|
|
|
logger.info(
|
|
|
|
instance.projectname)
|
|
|
|
"%s not a NGCP project, skip release_target", instance.projectname
|
|
|
|
|
|
|
|
)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
branch = instance.param_branch
|
|
|
|
branch = instance.param_branch
|
|
|
|
if workfront_re_branch.search(branch):
|
|
|
|
if workfront_re_branch.search(branch):
|
|
|
@ -82,15 +84,14 @@ def workfront_note_add(instance, message, release_target=False):
|
|
|
|
if not instance.gerrit_eventtype:
|
|
|
|
if not instance.gerrit_eventtype:
|
|
|
|
change = WorkfrontNoteInfo.getCommit(instance.git_commit_msg)
|
|
|
|
change = WorkfrontNoteInfo.getCommit(instance.git_commit_msg)
|
|
|
|
url = settings.GITWEB_URL.format(instance.projectname, change)
|
|
|
|
url = settings.GITWEB_URL.format(instance.projectname, change)
|
|
|
|
eventtype = 'git-commit'
|
|
|
|
eventtype = "git-commit"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
change = instance.gerrit_change
|
|
|
|
change = instance.gerrit_change
|
|
|
|
url = settings.GERRIT_URL.format(instance.gerrit_change)
|
|
|
|
url = settings.GERRIT_URL.format(instance.gerrit_change)
|
|
|
|
eventtype = instance.gerrit_eventtype
|
|
|
|
eventtype = instance.gerrit_eventtype
|
|
|
|
note, created = wni.get_or_create(
|
|
|
|
note, created = wni.get_or_create(
|
|
|
|
workfront_id=wid,
|
|
|
|
workfront_id=wid, gerrit_change=change, eventtype=eventtype
|
|
|
|
gerrit_change=change,
|
|
|
|
)
|
|
|
|
eventtype=eventtype)
|
|
|
|
|
|
|
|
if created:
|
|
|
|
if created:
|
|
|
|
if not utils.workfront_note_send(wid, "%s %s " % (message, url)):
|
|
|
|
if not utils.workfront_note_send(wid, "%s %s " % (message, url)):
|
|
|
|
logger.error("remove related WorkfrontNoteInfo")
|
|
|
|
logger.error("remove related WorkfrontNoteInfo")
|
|
|
@ -106,16 +107,19 @@ def workfront_note_manage(sender, **kwargs):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
if kwargs["created"]:
|
|
|
|
if kwargs["created"]:
|
|
|
|
instance = kwargs["instance"]
|
|
|
|
instance = kwargs["instance"]
|
|
|
|
if instance.jobname.endswith("-get-code") and \
|
|
|
|
if instance.result != "SUCCESS":
|
|
|
|
instance.result == "SUCCESS":
|
|
|
|
return
|
|
|
|
|
|
|
|
if instance.jobname.endswith("-get-code"):
|
|
|
|
set_release_target = True
|
|
|
|
set_release_target = True
|
|
|
|
if instance.gerrit_eventtype == 'change-merged':
|
|
|
|
if instance.gerrit_eventtype == "change-merged":
|
|
|
|
msg = "%s.git[%s] review merged"
|
|
|
|
msg = "%s.git[%s] review merged"
|
|
|
|
elif instance.gerrit_eventtype == 'patchset-created':
|
|
|
|
elif instance.gerrit_eventtype == "patchset-created":
|
|
|
|
msg = "%s.git[%s] review created"
|
|
|
|
msg = "%s.git[%s] review created"
|
|
|
|
set_release_target = False
|
|
|
|
set_release_target = False
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
msg = "%s.git[%s] commit created"
|
|
|
|
msg = "%s.git[%s] commit created"
|
|
|
|
workfront_note_add(instance, msg % (instance.projectname,
|
|
|
|
workfront_note_add(
|
|
|
|
instance.param_branch),
|
|
|
|
instance,
|
|
|
|
set_release_target)
|
|
|
|
msg % (instance.projectname, instance.param_branch),
|
|
|
|
|
|
|
|
set_release_target,
|
|
|
|
|
|
|
|
)
|
|
|
|