예제 #1
0
                    id,
                    json.dumps(payload),
                    passwd_file=
                    "/var/lib/jenkins/secrets/github_hook_secret_cmsbot")
            except Exception as e:
                print "Xml parsing error", logFile, e
running_builds_elastic = {}
content = get_payload('jenkins-*', query_running_builds)
if content == "":
    running_builds_elastic = []
else:
    content_hash = json.loads(content)
    if (not 'hits' in content_hash) or (not 'hits' in content_hash['hits']):
        print "ERROR: ", content
        sys.exit(1)
    for hit in content_hash['hits']['hits']:
        if hit["_index"].startswith("jenkins-jobs-") or hit[
                "_index"].startswith("cmssdt-jenkins-jobs-"):
            try:
                print "Running:", hit["_source"]['job_name'], hit["_source"][
                    'build_number'], hit["_index"], hit['_id']
            except:
                pass
            running_builds_elastic[hit['_id']] = hit
for build in running_builds_elastic:
    if build not in all_local:
        hit = running_builds_elastic[build]
        hit["_source"]["job_status"] = "Failed"
        resend_payload(hit)
        print "job status marked as Failed"
예제 #2
0
        if build_result is not None:
          payload['build_result'] = build_result.text
          payload['build_duration'] = int(int(root.find('duration').text)/1000)
          payload['job_status'] = 'Finished'
          os.system('touch "' + flagFile + '"')
        else:
          payload['job_status'] = 'Running'
          all_local.append(id)
        weekindex="jenkins-jobs-"+str(int((((int(jstime)/1000)/86400)+4)/7))
        send_payload(weekindex,document,id,json.dumps(payload), passwd_file="/var/lib/jenkins/secrets/github_hook_secret_cmsbot")
      except Exception as e:
        print "Xml parsing error",logFile , e
running_builds_elastic={}
content = get_payload(query_url,query_running_builds)
if content == "":
  running_builds_elastic = []
else:
  content_hash = json.loads(content)
  for hit in content_hash['hits']['hits']:
    if hit["_index"]=="jenkins" or hit["_index"].startswith("jenkins-jobs-"):
      try:print "Running:",hit["_source"]['job_name'],hit["_source"]['build_number'],hit["_index"],hit['_id']
      except: pass
      running_builds_elastic[hit['_id']]=hit
for build in running_builds_elastic:
  if build not in all_local:
    hit = running_builds_elastic[build]
    hit["_source"]["job_status"]="Failed"
    resend_payload(hit,passwd_file="/var/lib/jenkins/secrets/github_hook_secret_cmsbot")
    print "job status marked as Failed"

예제 #3
0
        payload['slave_node'] = root.find('builtOn').text
        build_result = root.find('result')
        if build_result is not None:
          payload['build_result'] = build_result.text
          payload['build_duration'] = int(int(root.find('duration').text)/1000)
          payload['job_status'] = 'Finished'
          os.system('touch "' + flagFile + '"')
        else:
          payload['job_status'] = 'Running'
          all_local.append(id)
        weekindex="jenkins-jobs-"+str(int((((int(jstime)/1000)/86400)+4)/7))
        send_payload(weekindex,document,id,json.dumps(payload), passwd_file="/var/lib/jenkins/secrets/github_hook_secret_cmsbot")
      except Exception as e:
        print "Xml parsing error" , e
running_builds_elastic={}
content = get_payload(query_url,query_running_builds)
if content == "":
  running_builds_elastic = []
else:
  content_hash = json.loads(content)
  for hit in content_hash['hits']['hits']:
    if hit["_index"]=="jenkins" or hit["_index"].startswith("jenkins-jobs-"):
      running_builds_elastic[hit['_id']]=hit
for build in running_builds_elastic:
  if build not in all_local:
    hit = running_builds_elastic[build]
    hit["job_status"]="Failed"
    resend_payload(hit,passwd_file="/var/lib/jenkins/secrets/github_hook_secret_cmsbot")
    print "job status marked as Failed"

예제 #4
0
          payload['job_status'] = 'Finished'
          os.system('touch "' + flagFile + '"')
        else:
          payload['job_status'] = 'Running'
          all_local.append(id)
        weekindex="jenkins-jobs-"+str(int((((int(jstime)/1000)/86400)+4)/7))
        send_payload(weekindex,document,id,json.dumps(payload))
      except Exception as e:
        print("Xml parsing error",logFile , e)
running_builds_elastic={}
content = get_payload('jenkins-*',query_running_builds)
if content == "":
  running_builds_elastic = []
else:
  content_hash = json.loads(content)
  if (not 'hits' in content_hash) or (not 'hits' in content_hash['hits']):
    print("ERROR: ",content)
    sys.exit(1)
  for hit in content_hash['hits']['hits']:
    if hit["_index"].startswith("jenkins-jobs-") or hit["_index"].startswith("cmssdt-jenkins-jobs-"):
      try:print("Running:",hit["_source"]['job_name'],hit["_source"]['build_number'],hit["_index"],hit['_id'])
      except: pass
      running_builds_elastic[hit['_id']]=hit
for build in running_builds_elastic:
  if build not in all_local:
    hit = running_builds_elastic[build]
    hit["_source"]["job_status"]="Failed"
    resend_payload(hit)
    print("job status marked as Failed")