{"action":"created","comment":{"url":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/comments/88645111","pull_request_review_id":9212179,"id":88645111,"diff_hunk":"@@ -848,3 +867,59 @@ def test_workflow_plugin_results():\n     assert workflow.postbuild_results == {'post_build_value': 'post_build_value_result'}\n     assert workflow.prepub_results == {'pre_publish_value': 'pre_publish_value_result'}\n     assert workflow.exit_results == {'exit_value': 'exit_value_result'}\n+\n+\n+def test_cancel_build(request):\n+    \"\"\"\n+    Verifies that exit plugins are executed when the build is cancelled\n+    \"\"\"\n+    this_file = inspect.getfile(PreRaises)\n+    mock_docker()\n+    fake_builder = MockInsideBuilder()\n+    flexmock(InsideBuilder).new_instances(fake_builder)\n+\n+    watch_pre = Watcher()\n+    watch_prepub = Watcher()\n+    watch_post = WatcherWithPause()\n+    watch_exit = Watcher()\n+\n+    fake_logger = FakeLogger()\n+    existing_logger = atomic_reactor.plugin.logger\n+\n+    def restore_logger():\n+        atomic_reactor.plugin.logger = existing_logger\n+\n+    request.addfinalizer(restore_logger)\n+    atomic_reactor.plugin.logger = fake_logger\n+\n+    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image',\n+                                   prebuild_plugins=[{'name': 'pre_watched',\n+                                                      'args': {\n+                                                          'watcher': watch_pre\n+                                                      }}],\n+                                   prepublish_plugins=[{'name': 'prepub_watched',\n+                                                        'args': {\n+                                                            'watcher': watch_prepub,\n+                                                        }}],\n+                                   postbuild_plugins=[{'name': 'post_watched_raises',\n+                                                       'args': {\n+                                                           'watcher': watch_post\n+                                                       }}],\n+                                   exit_plugins=[{'name': 'exit_watched',\n+                                                  'args': {\n+                                                      'watcher': watch_exit\n+                                                  }}],\n+                                   plugin_files=[this_file])\n+\n+    pid = os.getpid()\n+    thread = threading.Thread(\n+        target=lambda: (\n+            sleep(2),\n+            os.kill(pid, signal.SIGTERM)))\n+    thread.start()\n+\n+    workflow.build_docker_image()\n+\n+    assert (\"plugin 'post_watched_raises' raised an exception:\" +\n+            \" BuildCanceledException('Build was cancelled',)\",) in fake_logger.warnings\n+    assert watch_exit.was_called()","path":"tests/test_inner.py","position":99,"original_position":99,"commit_id":"88d34b255670df48267c650da5bec64468445dde","original_commit_id":"88d34b255670df48267c650da5bec64468445dde","user":{"login":"twaugh","id":6985468,"avatar_url":"https://avatars.githubusercontent.com/u/6985468?v=3","gravatar_id":"","url":"https://api.github.com/users/twaugh","html_url":"https://github.com/twaugh","followers_url":"https://api.github.com/users/twaugh/followers","following_url":"https://api.github.com/users/twaugh/following{/other_user}","gists_url":"https://api.github.com/users/twaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/twaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twaugh/subscriptions","organizations_url":"https://api.github.com/users/twaugh/orgs","repos_url":"https://api.github.com/users/twaugh/repos","events_url":"https://api.github.com/users/twaugh/events{/privacy}","received_events_url":"https://api.github.com/users/twaugh/received_events","type":"User","site_admin":false},"body":"We should assert whether each phase was called.","created_at":"2016-11-18T11:59:31Z","updated_at":"2016-11-18T11:59:37Z","html_url":"https://github.com/projectatomic/atomic-reactor/pull/585#discussion_r88645111","pull_request_url":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/585","_links":{"self":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/comments/88645111"},"html":{"href":"https://github.com/projectatomic/atomic-reactor/pull/585#discussion_r88645111"},"pull_request":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/585"}}},"pull_request":{"url":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/585","id":93777787,"html_url":"https://github.com/projectatomic/atomic-reactor/pull/585","diff_url":"https://github.com/projectatomic/atomic-reactor/pull/585.diff","patch_url":"https://github.com/projectatomic/atomic-reactor/pull/585.patch","issue_url":"https://api.github.com/repos/projectatomic/atomic-reactor/issues/585","number":585,"state":"open","locked":false,"title":"Run exit plugins if the build has been cancelled","user":{"login":"vrutkovs","id":114501,"avatar_url":"https://avatars.githubusercontent.com/u/114501?v=3","gravatar_id":"","url":"https://api.github.com/users/vrutkovs","html_url":"https://github.com/vrutkovs","followers_url":"https://api.github.com/users/vrutkovs/followers","following_url":"https://api.github.com/users/vrutkovs/following{/other_user}","gists_url":"https://api.github.com/users/vrutkovs/gists{/gist_id}","starred_url":"https://api.github.com/users/vrutkovs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrutkovs/subscriptions","organizations_url":"https://api.github.com/users/vrutkovs/orgs","repos_url":"https://api.github.com/users/vrutkovs/repos","events_url":"https://api.github.com/users/vrutkovs/events{/privacy}","received_events_url":"https://api.github.com/users/vrutkovs/received_events","type":"User","site_admin":false},"body":"Docker sends SIGTERM to a container when its stopped (OSE build is cancelled).\r\n\r\nThis PR traps the signal and throws an  exception in the process if the build or pre-/post-build plugins are running. The signal handler will ignore the exception if exit plugins are running.\r\n\r\nDefault docker timeout is 30 secs, so exit plugins have plenty of time to finish.\r\n\r\nTODO:\r\n - [x] Add tests","created_at":"2016-11-15T14:42:36Z","updated_at":"2016-11-18T11:59:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12b2820d1327688022474cff5bc7dcc6e0055a72","assignee":{"login":"lcarva","id":5272931,"avatar_url":"https://avatars.githubusercontent.com/u/5272931?v=3","gravatar_id":"","url":"https://api.github.com/users/lcarva","html_url":"https://github.com/lcarva","followers_url":"https://api.github.com/users/lcarva/followers","following_url":"https://api.github.com/users/lcarva/following{/other_user}","gists_url":"https://api.github.com/users/lcarva/gists{/gist_id}","starred_url":"https://api.github.com/users/lcarva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcarva/subscriptions","organizations_url":"https://api.github.com/users/lcarva/orgs","repos_url":"https://api.github.com/users/lcarva/repos","events_url":"https://api.github.com/users/lcarva/events{/privacy}","received_events_url":"https://api.github.com/users/lcarva/received_events","type":"User","site_admin":false},"assignees":[{"login":"lcarva","id":5272931,"avatar_url":"https://avatars.githubusercontent.com/u/5272931?v=3","gravatar_id":"","url":"https://api.github.com/users/lcarva","html_url":"https://github.com/lcarva","followers_url":"https://api.github.com/users/lcarva/followers","following_url":"https://api.github.com/users/lcarva/following{/other_user}","gists_url":"https://api.github.com/users/lcarva/gists{/gist_id}","starred_url":"https://api.github.com/users/lcarva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcarva/subscriptions","organizations_url":"https://api.github.com/users/lcarva/orgs","repos_url":"https://api.github.com/users/lcarva/repos","events_url":"https://api.github.com/users/lcarva/events{/privacy}","received_events_url":"https://api.github.com/users/lcarva/received_events","type":"User","site_admin":false},{"login":"twaugh","id":6985468,"avatar_url":"https://avatars.githubusercontent.com/u/6985468?v=3","gravatar_id":"","url":"https://api.github.com/users/twaugh","html_url":"https://github.com/twaugh","followers_url":"https://api.github.com/users/twaugh/followers","following_url":"https://api.github.com/users/twaugh/following{/other_user}","gists_url":"https://api.github.com/users/twaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/twaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twaugh/subscriptions","organizations_url":"https://api.github.com/users/twaugh/orgs","repos_url":"https://api.github.com/users/twaugh/repos","events_url":"https://api.github.com/users/twaugh/events{/privacy}","received_events_url":"https://api.github.com/users/twaugh/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/585/commits","review_comments_url":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/585/comments","review_comment_url":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/projectatomic/atomic-reactor/issues/585/comments","statuses_url":"https://api.github.com/repos/projectatomic/atomic-reactor/statuses/88d34b255670df48267c650da5bec64468445dde","head":{"label":"vrutkovs:exit-plugins-cancel","ref":"exit-plugins-cancel","sha":"88d34b255670df48267c650da5bec64468445dde","user":{"login":"vrutkovs","id":114501,"avatar_url":"https://avatars.githubusercontent.com/u/114501?v=3","gravatar_id":"","url":"https://api.github.com/users/vrutkovs","html_url":"https://github.com/vrutkovs","followers_url":"https://api.github.com/users/vrutkovs/followers","following_url":"https://api.github.com/users/vrutkovs/following{/other_user}","gists_url":"https://api.github.com/users/vrutkovs/gists{/gist_id}","starred_url":"https://api.github.com/users/vrutkovs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrutkovs/subscriptions","organizations_url":"https://api.github.com/users/vrutkovs/orgs","repos_url":"https://api.github.com/users/vrutkovs/repos","events_url":"https://api.github.com/users/vrutkovs/events{/privacy}","received_events_url":"https://api.github.com/users/vrutkovs/received_events","type":"User","site_admin":false},"repo":{"id":52874388,"name":"atomic-reactor","full_name":"vrutkovs/atomic-reactor","owner":{"login":"vrutkovs","id":114501,"avatar_url":"https://avatars.githubusercontent.com/u/114501?v=3","gravatar_id":"","url":"https://api.github.com/users/vrutkovs","html_url":"https://github.com/vrutkovs","followers_url":"https://api.github.com/users/vrutkovs/followers","following_url":"https://api.github.com/users/vrutkovs/following{/other_user}","gists_url":"https://api.github.com/users/vrutkovs/gists{/gist_id}","starred_url":"https://api.github.com/users/vrutkovs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrutkovs/subscriptions","organizations_url":"https://api.github.com/users/vrutkovs/orgs","repos_url":"https://api.github.com/users/vrutkovs/repos","events_url":"https://api.github.com/users/vrutkovs/events{/privacy}","received_events_url":"https://api.github.com/users/vrutkovs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vrutkovs/atomic-reactor","description":"Simple python library for building docker images.","fork":true,"url":"https://api.github.com/repos/vrutkovs/atomic-reactor","forks_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/forks","keys_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/teams","hooks_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/hooks","issue_events_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/issues/events{/number}","events_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/events","assignees_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/assignees{/user}","branches_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/branches{/branch}","tags_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/tags","blobs_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/git/refs{/sha}","trees_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/statuses/{sha}","languages_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/languages","stargazers_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/stargazers","contributors_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/contributors","subscribers_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/subscribers","subscription_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/subscription","commits_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/commits{/sha}","git_commits_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/git/commits{/sha}","comments_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/comments{/number}","issue_comment_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/issues/comments{/number}","contents_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/contents/{+path}","compare_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/merges","archive_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/downloads","issues_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/issues{/number}","pulls_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/pulls{/number}","milestones_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/milestones{/number}","notifications_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/labels{/name}","releases_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/releases{/id}","deployments_url":"https://api.github.com/repos/vrutkovs/atomic-reactor/deployments","created_at":"2016-03-01T12:15:50Z","updated_at":"2016-03-01T12:15:51Z","pushed_at":"2016-11-18T11:31:01Z","git_url":"git://github.com/vrutkovs/atomic-reactor.git","ssh_url":"git@github.com:vrutkovs/atomic-reactor.git","clone_url":"https://github.com/vrutkovs/atomic-reactor.git","svn_url":"https://github.com/vrutkovs/atomic-reactor","homepage":"","size":1606,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"projectatomic:master","ref":"master","sha":"f9225206a2105eda178e611af451c9e13d8a095a","user":{"login":"projectatomic","id":6852258,"avatar_url":"https://avatars.githubusercontent.com/u/6852258?v=3","gravatar_id":"","url":"https://api.github.com/users/projectatomic","html_url":"https://github.com/projectatomic","followers_url":"https://api.github.com/users/projectatomic/followers","following_url":"https://api.github.com/users/projectatomic/following{/other_user}","gists_url":"https://api.github.com/users/projectatomic/gists{/gist_id}","starred_url":"https://api.github.com/users/projectatomic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectatomic/subscriptions","organizations_url":"https://api.github.com/users/projectatomic/orgs","repos_url":"https://api.github.com/users/projectatomic/repos","events_url":"https://api.github.com/users/projectatomic/events{/privacy}","received_events_url":"https://api.github.com/users/projectatomic/received_events","type":"Organization","site_admin":false},"repo":{"id":25527782,"name":"atomic-reactor","full_name":"projectatomic/atomic-reactor","owner":{"login":"projectatomic","id":6852258,"avatar_url":"https://avatars.githubusercontent.com/u/6852258?v=3","gravatar_id":"","url":"https://api.github.com/users/projectatomic","html_url":"https://github.com/projectatomic","followers_url":"https://api.github.com/users/projectatomic/followers","following_url":"https://api.github.com/users/projectatomic/following{/other_user}","gists_url":"https://api.github.com/users/projectatomic/gists{/gist_id}","starred_url":"https://api.github.com/users/projectatomic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/projectatomic/subscriptions","organizations_url":"https://api.github.com/users/projectatomic/orgs","repos_url":"https://api.github.com/users/projectatomic/repos","events_url":"https://api.github.com/users/projectatomic/events{/privacy}","received_events_url":"https://api.github.com/users/projectatomic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/projectatomic/atomic-reactor","description":"Simple python library for building docker images.","fork":false,"url":"https://api.github.com/repos/projectatomic/atomic-reactor","forks_url":"https://api.github.com/repos/projectatomic/atomic-reactor/forks","keys_url":"https://api.github.com/repos/projectatomic/atomic-reactor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/projectatomic/atomic-reactor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/projectatomic/atomic-reactor/teams","hooks_url":"https://api.github.com/repos/projectatomic/atomic-reactor/hooks","issue_events_url":"https://api.github.com/repos/projectatomic/atomic-reactor/issues/events{/number}","events_url":"https://api.github.com/repos/projectatomic/atomic-reactor/events","assignees_url":"https://api.github.com/repos/projectatomic/atomic-reactor/assignees{/user}","branches_url":"https://api.github.com/repos/projectatomic/atomic-reactor/branches{/branch}","tags_url":"https://api.github.com/repos/projectatomic/atomic-reactor/tags","blobs_url":"https://api.github.com/repos/projectatomic/atomic-reactor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/projectatomic/atomic-reactor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/projectatomic/atomic-reactor/git/refs{/sha}","trees_url":"https://api.github.com/repos/projectatomic/atomic-reactor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/projectatomic/atomic-reactor/statuses/{sha}","languages_url":"https://api.github.com/repos/projectatomic/atomic-reactor/languages","stargazers_url":"https://api.github.com/repos/projectatomic/atomic-reactor/stargazers","contributors_url":"https://api.github.com/repos/projectatomic/atomic-reactor/contributors","subscribers_url":"https://api.github.com/repos/projectatomic/atomic-reactor/subscribers","subscription_url":"https://api.github.com/repos/projectatomic/atomic-reactor/subscription","commits_url":"https://api.github.com/repos/projectatomic/atomic-reactor/commits{/sha}","git_commits_url":"https://api.github.com/repos/projectatomic/atomic-reactor/git/commits{/sha}","comments_url":"https://api.github.com/repos/projectatomic/atomic-reactor/comments{/number}","issue_comment_url":"https://api.github.com/repos/projectatomic/atomic-reactor/issues/comments{/number}","contents_url":"https://api.github.com/repos/projectatomic/atomic-reactor/contents/{+path}","compare_url":"https://api.github.com/repos/projectatomic/atomic-reactor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/projectatomic/atomic-reactor/merges","archive_url":"https://api.github.com/repos/projectatomic/atomic-reactor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/projectatomic/atomic-reactor/downloads","issues_url":"https://api.github.com/repos/projectatomic/atomic-reactor/issues{/number}","pulls_url":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls{/number}","milestones_url":"https://api.github.com/repos/projectatomic/atomic-reactor/milestones{/number}","notifications_url":"https://api.github.com/repos/projectatomic/atomic-reactor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/projectatomic/atomic-reactor/labels{/name}","releases_url":"https://api.github.com/repos/projectatomic/atomic-reactor/releases{/id}","deployments_url":"https://api.github.com/repos/projectatomic/atomic-reactor/deployments","created_at":"2014-10-21T14:45:11Z","updated_at":"2016-10-25T17:38:32Z","pushed_at":"2016-11-18T11:31:01Z","git_url":"git://github.com/projectatomic/atomic-reactor.git","ssh_url":"git@github.com:projectatomic/atomic-reactor.git","clone_url":"https://github.com/projectatomic/atomic-reactor.git","svn_url":"https://github.com/projectatomic/atomic-reactor","homepage":"","size":1707,"stargazers_count":67,"watchers_count":67,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":51,"forks":26,"open_issues":51,"watchers":67,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/585"},"html":{"href":"https://github.com/projectatomic/atomic-reactor/pull/585"},"issue":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/issues/585"},"comments":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/issues/585/comments"},"review_comments":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/585/comments"},"review_comment":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/pulls/585/commits"},"statuses":{"href":"https://api.github.com/repos/projectatomic/atomic-reactor/statuses/88d34b255670df48267c650da5bec64468445dde"}}}}
{"actor":{"display_login":"twaugh"}}