{"action":"created","comment":{"url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/comments/210462371","pull_request_review_id":146681501,"id":210462371,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDQ2MjM3MQ==","diff_hunk":"@@ -107,26 +111,33 @@ public boolean shouldSchedule(Queue.Task p, List<Action> actions) {\n         logger.info(\"Triggering OpenShift Build for WorkflowJob \" + wj.getFullName() + \" due to \" + causeDescription(actions));\n         BuildConfig foundBuildConfig = OpenShiftUtils.findBCbyNameOrLabel(getOpenShiftClient(), namespace, buildConfigname);\n         if (foundBuildConfig != null) {\n+          int buildInJenkins = wj.getLastBuild()!=null ? wj.getLastBuild().number : 0;\n           buildConfigname = foundBuildConfig.getMetadata().getName();\n-          triggerBuildRequest(buildConfigname, namespace, jobURL);\n+          if (isPRBuild && cancelPRBuildOnUpdate && (buildInJenkins > 0 || (buildInJenkins == 0 && isJobInQueue(wj)))) {","path":"src/main/java/io/fabric8/jenkins/openshiftsync/BuildDecisionHandler.java","position":69,"original_position":69,"commit_id":"5ad6aaf4fe8e9a434ad2d14461b618124ef418ca","original_commit_id":"5ad6aaf4fe8e9a434ad2d14461b618124ef418ca","user":{"login":"sthaha","id":3005132,"node_id":"MDQ6VXNlcjMwMDUxMzI=","avatar_url":"https://avatars0.githubusercontent.com/u/3005132?v=4","gravatar_id":"","url":"https://api.github.com/users/sthaha","html_url":"https://github.com/sthaha","followers_url":"https://api.github.com/users/sthaha/followers","following_url":"https://api.github.com/users/sthaha/following{/other_user}","gists_url":"https://api.github.com/users/sthaha/gists{/gist_id}","starred_url":"https://api.github.com/users/sthaha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sthaha/subscriptions","organizations_url":"https://api.github.com/users/sthaha/orgs","repos_url":"https://api.github.com/users/sthaha/repos","events_url":"https://api.github.com/users/sthaha/events{/privacy}","received_events_url":"https://api.github.com/users/sthaha/received_events","type":"User","site_admin":false},"body":"instead of nesting, you may be able to make it flatter (easier to understand) if you exit early; e.g.\r\n\r\n```java\r\nif (foo) {\r\n  something()\r\n  if (bar) {\r\n    somethingElse();\r\n      if (bar) {\r\n        someMoreThings()\r\n      }\r\n  }\r\n}\r\n```\r\n\r\ncan be better written as \r\n```java\r\n\r\nif (!foo) {\r\n  return \r\n}\r\nsomething()\r\n\r\nif (!bar) {\r\nreturn\r\n}\r\nsomethingElse()\r\n\r\nif (!baz) {\r\n  return\r\n}\r\n\r\nsomeMoreThings();\r\n\r\n```\r\n","created_at":"2018-08-16T02:26:41Z","updated_at":"2018-08-16T02:26:41Z","html_url":"https://github.com/fabric8io/jenkins-sync-plugin/pull/40#discussion_r210462371","pull_request_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/40","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/comments/210462371"},"html":{"href":"https://github.com/fabric8io/jenkins-sync-plugin/pull/40#discussion_r210462371"},"pull_request":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/40"}}},"pull_request":{"url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/40","id":205786947,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1Nzg2OTQ3","html_url":"https://github.com/fabric8io/jenkins-sync-plugin/pull/40","diff_url":"https://github.com/fabric8io/jenkins-sync-plugin/pull/40.diff","patch_url":"https://github.com/fabric8io/jenkins-sync-plugin/pull/40.patch","issue_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/issues/40","number":40,"state":"closed","locked":false,"title":"Fix cancelling build when PR is updated","user":{"login":"piyush1594","id":19270240,"node_id":"MDQ6VXNlcjE5MjcwMjQw","avatar_url":"https://avatars1.githubusercontent.com/u/19270240?v=4","gravatar_id":"","url":"https://api.github.com/users/piyush1594","html_url":"https://github.com/piyush1594","followers_url":"https://api.github.com/users/piyush1594/followers","following_url":"https://api.github.com/users/piyush1594/following{/other_user}","gists_url":"https://api.github.com/users/piyush1594/gists{/gist_id}","starred_url":"https://api.github.com/users/piyush1594/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piyush1594/subscriptions","organizations_url":"https://api.github.com/users/piyush1594/orgs","repos_url":"https://api.github.com/users/piyush1594/repos","events_url":"https://api.github.com/users/piyush1594/events{/privacy}","received_events_url":"https://api.github.com/users/piyush1594/received_events","type":"User","site_admin":false},"body":"This will add the feature of cancelling PR build\r\nif the PR is updated as the previous change is no more\r\nmeaningful\r\nIf you update a PR which is building it will cancel the build\r\nand will schedule a new one.\r\nIf you update a PR whose build in in queue it will\r\nremove that build from queue and schedule new one\r\n\r\nAdd the flag `cancelPRBuildOnUpdate` to enable this feature\r\notherwise making this flag false will build all PR updates\r\n\r\nFixes #38\r\nFixes openshiftio/openshift.io#3862","created_at":"2018-08-02T16:07:47Z","updated_at":"2018-08-16T02:26:41Z","closed_at":"2018-08-13T09:11:59Z","merged_at":"2018-08-13T09:11:59Z","merge_commit_sha":"29d7ce824ce31cb2ce3ae51a74ae52c59953799d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"rupalibehera","id":4288561,"node_id":"MDQ6VXNlcjQyODg1NjE=","avatar_url":"https://avatars3.githubusercontent.com/u/4288561?v=4","gravatar_id":"","url":"https://api.github.com/users/rupalibehera","html_url":"https://github.com/rupalibehera","followers_url":"https://api.github.com/users/rupalibehera/followers","following_url":"https://api.github.com/users/rupalibehera/following{/other_user}","gists_url":"https://api.github.com/users/rupalibehera/gists{/gist_id}","starred_url":"https://api.github.com/users/rupalibehera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rupalibehera/subscriptions","organizations_url":"https://api.github.com/users/rupalibehera/orgs","repos_url":"https://api.github.com/users/rupalibehera/repos","events_url":"https://api.github.com/users/rupalibehera/events{/privacy}","received_events_url":"https://api.github.com/users/rupalibehera/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/40/commits","review_comments_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/40/comments","review_comment_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/issues/40/comments","statuses_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/statuses/5ad6aaf4fe8e9a434ad2d14461b618124ef418ca","head":{"label":"piyush1594:iss_38","ref":"iss_38","sha":"5ad6aaf4fe8e9a434ad2d14461b618124ef418ca","user":{"login":"piyush1594","id":19270240,"node_id":"MDQ6VXNlcjE5MjcwMjQw","avatar_url":"https://avatars1.githubusercontent.com/u/19270240?v=4","gravatar_id":"","url":"https://api.github.com/users/piyush1594","html_url":"https://github.com/piyush1594","followers_url":"https://api.github.com/users/piyush1594/followers","following_url":"https://api.github.com/users/piyush1594/following{/other_user}","gists_url":"https://api.github.com/users/piyush1594/gists{/gist_id}","starred_url":"https://api.github.com/users/piyush1594/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piyush1594/subscriptions","organizations_url":"https://api.github.com/users/piyush1594/orgs","repos_url":"https://api.github.com/users/piyush1594/repos","events_url":"https://api.github.com/users/piyush1594/events{/privacy}","received_events_url":"https://api.github.com/users/piyush1594/received_events","type":"User","site_admin":false},"repo":{"id":114131857,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQxMzE4NTc=","name":"jenkins-sync-plugin","full_name":"piyush1594/jenkins-sync-plugin","owner":{"login":"piyush1594","id":19270240,"node_id":"MDQ6VXNlcjE5MjcwMjQw","avatar_url":"https://avatars1.githubusercontent.com/u/19270240?v=4","gravatar_id":"","url":"https://api.github.com/users/piyush1594","html_url":"https://github.com/piyush1594","followers_url":"https://api.github.com/users/piyush1594/followers","following_url":"https://api.github.com/users/piyush1594/following{/other_user}","gists_url":"https://api.github.com/users/piyush1594/gists{/gist_id}","starred_url":"https://api.github.com/users/piyush1594/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piyush1594/subscriptions","organizations_url":"https://api.github.com/users/piyush1594/orgs","repos_url":"https://api.github.com/users/piyush1594/repos","events_url":"https://api.github.com/users/piyush1594/events{/privacy}","received_events_url":"https://api.github.com/users/piyush1594/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/piyush1594/jenkins-sync-plugin","description":"Synchronizes OpenShift BuildConfig objects using Jenkins as Jenkins jobs, then synchronizes build statuses into the OpenShift Build objects","fork":true,"url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin","forks_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/forks","keys_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/teams","hooks_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/hooks","issue_events_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/events","assignees_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/tags","blobs_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/languages","stargazers_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/stargazers","contributors_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/contributors","subscribers_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/subscribers","subscription_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/subscription","commits_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/merges","archive_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/downloads","issues_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/labels{/name}","releases_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/piyush1594/jenkins-sync-plugin/deployments","created_at":"2017-12-13T14:37:42Z","updated_at":"2017-12-13T14:37:44Z","pushed_at":"2018-08-09T15:13:16Z","git_url":"git://github.com/piyush1594/jenkins-sync-plugin.git","ssh_url":"git@github.com:piyush1594/jenkins-sync-plugin.git","clone_url":"https://github.com/piyush1594/jenkins-sync-plugin.git","svn_url":"https://github.com/piyush1594/jenkins-sync-plugin","homepage":null,"size":819,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fabric8io:job-to-bc","ref":"job-to-bc","sha":"807da5aba0e356791fc816a522490f2b45db8b21","user":{"login":"fabric8io","id":6074349,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNzQzNDk=","avatar_url":"https://avatars1.githubusercontent.com/u/6074349?v=4","gravatar_id":"","url":"https://api.github.com/users/fabric8io","html_url":"https://github.com/fabric8io","followers_url":"https://api.github.com/users/fabric8io/followers","following_url":"https://api.github.com/users/fabric8io/following{/other_user}","gists_url":"https://api.github.com/users/fabric8io/gists{/gist_id}","starred_url":"https://api.github.com/users/fabric8io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabric8io/subscriptions","organizations_url":"https://api.github.com/users/fabric8io/orgs","repos_url":"https://api.github.com/users/fabric8io/repos","events_url":"https://api.github.com/users/fabric8io/events{/privacy}","received_events_url":"https://api.github.com/users/fabric8io/received_events","type":"Organization","site_admin":false},"repo":{"id":84092650,"node_id":"MDEwOlJlcG9zaXRvcnk4NDA5MjY1MA==","name":"jenkins-sync-plugin","full_name":"fabric8io/jenkins-sync-plugin","owner":{"login":"fabric8io","id":6074349,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYwNzQzNDk=","avatar_url":"https://avatars1.githubusercontent.com/u/6074349?v=4","gravatar_id":"","url":"https://api.github.com/users/fabric8io","html_url":"https://github.com/fabric8io","followers_url":"https://api.github.com/users/fabric8io/followers","following_url":"https://api.github.com/users/fabric8io/following{/other_user}","gists_url":"https://api.github.com/users/fabric8io/gists{/gist_id}","starred_url":"https://api.github.com/users/fabric8io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabric8io/subscriptions","organizations_url":"https://api.github.com/users/fabric8io/orgs","repos_url":"https://api.github.com/users/fabric8io/repos","events_url":"https://api.github.com/users/fabric8io/events{/privacy}","received_events_url":"https://api.github.com/users/fabric8io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fabric8io/jenkins-sync-plugin","description":"Synchronizes OpenShift BuildConfig objects using Jenkins as Jenkins jobs, then synchronizes build statuses into the OpenShift Build objects","fork":true,"url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin","forks_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/forks","keys_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/teams","hooks_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/hooks","issue_events_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/events","assignees_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/tags","blobs_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/languages","stargazers_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/stargazers","contributors_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/contributors","subscribers_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/subscribers","subscription_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/subscription","commits_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/merges","archive_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/downloads","issues_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/labels{/name}","releases_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/deployments","created_at":"2017-03-06T16:00:41Z","updated_at":"2018-08-13T09:12:02Z","pushed_at":"2018-08-13T09:11:59Z","git_url":"git://github.com/fabric8io/jenkins-sync-plugin.git","ssh_url":"git@github.com:fabric8io/jenkins-sync-plugin.git","clone_url":"https://github.com/fabric8io/jenkins-sync-plugin.git","svn_url":"https://github.com/fabric8io/jenkins-sync-plugin","homepage":null,"size":893,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4,"open_issues":5,"watchers":0,"default_branch":"job-to-bc"}},"_links":{"self":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/40"},"html":{"href":"https://github.com/fabric8io/jenkins-sync-plugin/pull/40"},"issue":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/issues/40"},"comments":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/fabric8io/jenkins-sync-plugin/statuses/5ad6aaf4fe8e9a434ad2d14461b618124ef418ca"}},"author_association":"NONE"}}
{"actor":{"display_login":"sthaha"}}