Merge pull request #2173 from charltonaustin/adding_in_build_cancel_notifications
Adding in cancel notifications
This commit is contained in:
commit
2c637fe5ce
9 changed files with 153 additions and 29 deletions
|
@ -0,0 +1,28 @@
|
|||
"""Create new notification type
|
||||
|
||||
Revision ID: 94836b099894
|
||||
Revises: faf752bd2e0a
|
||||
Create Date: 2016-11-30 10:29:51.519278
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '94836b099894'
|
||||
down_revision = 'faf752bd2e0a'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade(tables):
|
||||
op.bulk_insert(tables.externalnotificationevent,
|
||||
[
|
||||
{'name': 'build_cancelled'},
|
||||
])
|
||||
|
||||
|
||||
def downgrade(tables):
|
||||
op.execute(tables
|
||||
.externalnotificationevent
|
||||
.delete()
|
||||
.where(tables.
|
||||
externalnotificationevent.c.name == op.inline_literal('build_cancelled')))
|
|
@ -197,6 +197,7 @@ def cancel_repository_build(build, build_queue):
|
|||
""" This tries to cancel the build returns true if request is successful false if it can't be cancelled """
|
||||
with db_transaction():
|
||||
from app import build_canceller
|
||||
from buildman.jobutil.buildjob import BuildJobNotifier
|
||||
# Reload the build for update.
|
||||
# We are loading the build for update so checks should be as quick as possible.
|
||||
try:
|
||||
|
@ -210,6 +211,7 @@ def cancel_repository_build(build, build_queue):
|
|||
for cancelled in cancel_builds:
|
||||
if cancelled():
|
||||
build.phase = BUILD_PHASE.CANCELLED
|
||||
BuildJobNotifier(build.uuid).send_notification("build_cancelled")
|
||||
build.save()
|
||||
return True
|
||||
build.phase = original_phase
|
||||
|
|
Reference in a new issue