{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/test-pull-requests/pulls/comments/75331425","id":75331425,"diff_hunk":"@@ -1587,23 +1587,54 @@ popd\n       URI(build_url + \"/api/json\")\n     end\n \n-    def self.is_previous_build_running?(branch, settings)\n+    def self.previous_build_running?(branch, settings, repo)\n+      addtl_jenkins_params = branch_settings(branch, settings)['addtl_jenkins_params']\n       build_num = get_next_build(branch, settings) - 1\n       build_url = Properties['jenkins_url'] + 'job/' + branch_settings(branch, settings)['jenkins_job_name'] + \"/#{build_num}/\"\n+      previous_running = false\n+      consecutive_not_running_count = 0\n       get_session(branch, settings).start do |http|\n-        request = Net::HTTP::Get.new to_api_url(build_url).request_uri\n-        response = http.request request\n-        if response.kind_of? Net::HTTPSuccess\n-          return JSON.parse(response.body)[\"building\"]\n-        elsif response.kind_of? Net::HTTPNotFound\n-          return false # maybe someone deleted the last build?\n-        else\n-          return true # assume it's running to avoid errors causing multiple builds to start\n+        # Search for a running build of the same variety.  Don't run forever.\n+        100.times do\n+          # Break if you found one or if you run across a bunch of consecutive builds that aren't running you can assume you reached the end\n+          break if previous_running || consecutive_not_running_count >= 10\n+          request = Net::HTTP::Get.new to_api_url(build_url).request_uri\n+          response = http.request request\n+          if response.kind_of? Net::HTTPSuccess\n+            previous_running = build[\"building\"]\n+            build_json = JSON.parse(response.body)\n+            if previous_running\n+              consecutive_not_running_count = 0\n+              submitted_params = build_json['actions']['parameters']\n+              # Validate that the params match between the test settings and jenkins for cases that the same job is being used for multiple test commands\n+              if submitted_params && addtl_jenkins_params && addtl_jenkins_params[repo]\n+                submitted_param_map = {}\n+                submitted_params.each do |param|\n+                  submitted_param_map[param['name']] = param['value']\n+                end\n+                addtl_jenkins_params[repo].each do |key, value|\n+                  next if value == '*'\n+                  submitted_value = submitted_param_map[key]\n+                  if submitted_value && submitted_value != value\n+                    previous_running = false","path":"test_pull_requests","position":63,"original_position":60,"commit_id":"2c73cfc128f6ee7b1d606f9ebd784977cb55a5db","original_commit_id":"06b2b28b3b42bafa349d116e9725186bcbe7fb43","user":{"login":"stevekuznetsov","id":7328370,"avatar_url":"https://avatars.githubusercontent.com/u/7328370?v=3","gravatar_id":"","url":"https://api.github.com/users/stevekuznetsov","html_url":"https://github.com/stevekuznetsov","followers_url":"https://api.github.com/users/stevekuznetsov/followers","following_url":"https://api.github.com/users/stevekuznetsov/following{/other_user}","gists_url":"https://api.github.com/users/stevekuznetsov/gists{/gist_id}","starred_url":"https://api.github.com/users/stevekuznetsov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevekuznetsov/subscriptions","organizations_url":"https://api.github.com/users/stevekuznetsov/orgs","repos_url":"https://api.github.com/users/stevekuznetsov/repos","events_url":"https://api.github.com/users/stevekuznetsov/events{/privacy}","received_events_url":"https://api.github.com/users/stevekuznetsov/received_events","type":"User","site_admin":false},"body":"Right, so we have this case:\r\n```\r\nTEST  - RUNNING\r\nTEST  - FAILED\r\nMERGE - RUNNING\r\nTEST  - RUNNING\r\n```\r\n\r\nAs a result of parsing this, we should still have `previous_running=true` for merges at the end of that batch, right?","created_at":"2016-08-18T15:33:01Z","updated_at":"2016-08-18T15:33:01Z","html_url":"https://github.com/openshift/test-pull-requests/pull/37#discussion_r75331425","pull_request_url":"https://api.github.com/repos/openshift/test-pull-requests/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/openshift/test-pull-requests/pulls/comments/75331425"},"html":{"href":"https://github.com/openshift/test-pull-requests/pull/37#discussion_r75331425"},"pull_request":{"href":"https://api.github.com/repos/openshift/test-pull-requests/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/test-pull-requests/pulls/37","id":81829333,"html_url":"https://github.com/openshift/test-pull-requests/pull/37","diff_url":"https://github.com/openshift/test-pull-requests/pull/37.diff","patch_url":"https://github.com/openshift/test-pull-requests/pull/37.patch","issue_url":"https://api.github.com/repos/openshift/test-pull-requests/issues/37","number":37,"state":"open","locked":false,"title":"Search running jobs for param matches to double check for previous job","user":{"login":"danmcp","id":492994,"avatar_url":"https://avatars.githubusercontent.com/u/492994?v=3","gravatar_id":"","url":"https://api.github.com/users/danmcp","html_url":"https://github.com/danmcp","followers_url":"https://api.github.com/users/danmcp/followers","following_url":"https://api.github.com/users/danmcp/following{/other_user}","gists_url":"https://api.github.com/users/danmcp/gists{/gist_id}","starred_url":"https://api.github.com/users/danmcp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmcp/subscriptions","organizations_url":"https://api.github.com/users/danmcp/orgs","repos_url":"https://api.github.com/users/danmcp/repos","events_url":"https://api.github.com/users/danmcp/events{/privacy}","received_events_url":"https://api.github.com/users/danmcp/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-18T14:49:41Z","updated_at":"2016-08-18T15:33:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"790c57bb325c26507c796da8a6c7a6d384127352","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/openshift/test-pull-requests/pulls/37/commits","review_comments_url":"https://api.github.com/repos/openshift/test-pull-requests/pulls/37/comments","review_comment_url":"https://api.github.com/repos/openshift/test-pull-requests/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/test-pull-requests/issues/37/comments","statuses_url":"https://api.github.com/repos/openshift/test-pull-requests/statuses/2c73cfc128f6ee7b1d606f9ebd784977cb55a5db","head":{"label":"danmcp:master","ref":"master","sha":"2c73cfc128f6ee7b1d606f9ebd784977cb55a5db","user":{"login":"danmcp","id":492994,"avatar_url":"https://avatars.githubusercontent.com/u/492994?v=3","gravatar_id":"","url":"https://api.github.com/users/danmcp","html_url":"https://github.com/danmcp","followers_url":"https://api.github.com/users/danmcp/followers","following_url":"https://api.github.com/users/danmcp/following{/other_user}","gists_url":"https://api.github.com/users/danmcp/gists{/gist_id}","starred_url":"https://api.github.com/users/danmcp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmcp/subscriptions","organizations_url":"https://api.github.com/users/danmcp/orgs","repos_url":"https://api.github.com/users/danmcp/repos","events_url":"https://api.github.com/users/danmcp/events{/privacy}","received_events_url":"https://api.github.com/users/danmcp/received_events","type":"User","site_admin":false},"repo":{"id":17350835,"name":"test-pull-requests","full_name":"danmcp/test-pull-requests","owner":{"login":"danmcp","id":492994,"avatar_url":"https://avatars.githubusercontent.com/u/492994?v=3","gravatar_id":"","url":"https://api.github.com/users/danmcp","html_url":"https://github.com/danmcp","followers_url":"https://api.github.com/users/danmcp/followers","following_url":"https://api.github.com/users/danmcp/following{/other_user}","gists_url":"https://api.github.com/users/danmcp/gists{/gist_id}","starred_url":"https://api.github.com/users/danmcp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danmcp/subscriptions","organizations_url":"https://api.github.com/users/danmcp/orgs","repos_url":"https://api.github.com/users/danmcp/repos","events_url":"https://api.github.com/users/danmcp/events{/privacy}","received_events_url":"https://api.github.com/users/danmcp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danmcp/test-pull-requests","description":"Utility for serially testing then merging pull requests in conjunction with Jenkins.","fork":true,"url":"https://api.github.com/repos/danmcp/test-pull-requests","forks_url":"https://api.github.com/repos/danmcp/test-pull-requests/forks","keys_url":"https://api.github.com/repos/danmcp/test-pull-requests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danmcp/test-pull-requests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danmcp/test-pull-requests/teams","hooks_url":"https://api.github.com/repos/danmcp/test-pull-requests/hooks","issue_events_url":"https://api.github.com/repos/danmcp/test-pull-requests/issues/events{/number}","events_url":"https://api.github.com/repos/danmcp/test-pull-requests/events","assignees_url":"https://api.github.com/repos/danmcp/test-pull-requests/assignees{/user}","branches_url":"https://api.github.com/repos/danmcp/test-pull-requests/branches{/branch}","tags_url":"https://api.github.com/repos/danmcp/test-pull-requests/tags","blobs_url":"https://api.github.com/repos/danmcp/test-pull-requests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danmcp/test-pull-requests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danmcp/test-pull-requests/git/refs{/sha}","trees_url":"https://api.github.com/repos/danmcp/test-pull-requests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danmcp/test-pull-requests/statuses/{sha}","languages_url":"https://api.github.com/repos/danmcp/test-pull-requests/languages","stargazers_url":"https://api.github.com/repos/danmcp/test-pull-requests/stargazers","contributors_url":"https://api.github.com/repos/danmcp/test-pull-requests/contributors","subscribers_url":"https://api.github.com/repos/danmcp/test-pull-requests/subscribers","subscription_url":"https://api.github.com/repos/danmcp/test-pull-requests/subscription","commits_url":"https://api.github.com/repos/danmcp/test-pull-requests/commits{/sha}","git_commits_url":"https://api.github.com/repos/danmcp/test-pull-requests/git/commits{/sha}","comments_url":"https://api.github.com/repos/danmcp/test-pull-requests/comments{/number}","issue_comment_url":"https://api.github.com/repos/danmcp/test-pull-requests/issues/comments{/number}","contents_url":"https://api.github.com/repos/danmcp/test-pull-requests/contents/{+path}","compare_url":"https://api.github.com/repos/danmcp/test-pull-requests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danmcp/test-pull-requests/merges","archive_url":"https://api.github.com/repos/danmcp/test-pull-requests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danmcp/test-pull-requests/downloads","issues_url":"https://api.github.com/repos/danmcp/test-pull-requests/issues{/number}","pulls_url":"https://api.github.com/repos/danmcp/test-pull-requests/pulls{/number}","milestones_url":"https://api.github.com/repos/danmcp/test-pull-requests/milestones{/number}","notifications_url":"https://api.github.com/repos/danmcp/test-pull-requests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danmcp/test-pull-requests/labels{/name}","releases_url":"https://api.github.com/repos/danmcp/test-pull-requests/releases{/id}","deployments_url":"https://api.github.com/repos/danmcp/test-pull-requests/deployments","created_at":"2014-03-03T00:41:08Z","updated_at":"2016-01-21T22:06:28Z","pushed_at":"2016-08-18T15:29:20Z","git_url":"git://github.com/danmcp/test-pull-requests.git","ssh_url":"git@github.com:danmcp/test-pull-requests.git","clone_url":"https://github.com/danmcp/test-pull-requests.git","svn_url":"https://github.com/danmcp/test-pull-requests","homepage":null,"size":253,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"f2a0aed2eb5544221e720c7c7c04a88a98f6e5b0","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":5604195,"name":"test-pull-requests","full_name":"openshift/test-pull-requests","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/test-pull-requests","description":"Utility for serially testing then merging pull requests in conjunction with Jenkins.","fork":false,"url":"https://api.github.com/repos/openshift/test-pull-requests","forks_url":"https://api.github.com/repos/openshift/test-pull-requests/forks","keys_url":"https://api.github.com/repos/openshift/test-pull-requests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/test-pull-requests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/test-pull-requests/teams","hooks_url":"https://api.github.com/repos/openshift/test-pull-requests/hooks","issue_events_url":"https://api.github.com/repos/openshift/test-pull-requests/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/test-pull-requests/events","assignees_url":"https://api.github.com/repos/openshift/test-pull-requests/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/test-pull-requests/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/test-pull-requests/tags","blobs_url":"https://api.github.com/repos/openshift/test-pull-requests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/test-pull-requests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/test-pull-requests/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/test-pull-requests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/test-pull-requests/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/test-pull-requests/languages","stargazers_url":"https://api.github.com/repos/openshift/test-pull-requests/stargazers","contributors_url":"https://api.github.com/repos/openshift/test-pull-requests/contributors","subscribers_url":"https://api.github.com/repos/openshift/test-pull-requests/subscribers","subscription_url":"https://api.github.com/repos/openshift/test-pull-requests/subscription","commits_url":"https://api.github.com/repos/openshift/test-pull-requests/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/test-pull-requests/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/test-pull-requests/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/test-pull-requests/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/test-pull-requests/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/test-pull-requests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/test-pull-requests/merges","archive_url":"https://api.github.com/repos/openshift/test-pull-requests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/test-pull-requests/downloads","issues_url":"https://api.github.com/repos/openshift/test-pull-requests/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/test-pull-requests/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/test-pull-requests/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/test-pull-requests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/test-pull-requests/labels{/name}","releases_url":"https://api.github.com/repos/openshift/test-pull-requests/releases{/id}","deployments_url":"https://api.github.com/repos/openshift/test-pull-requests/deployments","created_at":"2012-08-29T17:45:58Z","updated_at":"2016-01-21T22:06:21Z","pushed_at":"2016-08-18T15:29:20Z","git_url":"git://github.com/openshift/test-pull-requests.git","ssh_url":"git@github.com:openshift/test-pull-requests.git","clone_url":"https://github.com/openshift/test-pull-requests.git","svn_url":"https://github.com/openshift/test-pull-requests","homepage":null,"size":286,"stargazers_count":12,"watchers_count":12,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":4,"forks":21,"open_issues":4,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/test-pull-requests/pulls/37"},"html":{"href":"https://github.com/openshift/test-pull-requests/pull/37"},"issue":{"href":"https://api.github.com/repos/openshift/test-pull-requests/issues/37"},"comments":{"href":"https://api.github.com/repos/openshift/test-pull-requests/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/test-pull-requests/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/test-pull-requests/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/test-pull-requests/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/test-pull-requests/statuses/2c73cfc128f6ee7b1d606f9ebd784977cb55a5db"}}}}
{"actor":{"display_login":"stevekuznetsov"}}