def get_jenkins_result(git_repo): jenkinsurl = git_repo.jenkins_url jobname = git_repo.jenkins_job_name job = Jenkins(jenkinsurl)[jobname] last_build_number = job.get_last_buildnumber() results = range(last_build_number) prev = True # The previous build status, used to determined fixer for i in range(last_build_number): build = job[i+1] #print build.get_revision() #this is actually commit id #print build.get_revision_branch() #contain in about branch commit = git_repo.commit_set.all().filter(commit_id=build.get_revision())[0] # commit_id should be unique author = commit.author if not build.is_good(): # Find a commit that matches the id of broken builds commit.break_build_status = 1 commit.save() author.num_break_build += 1 author.save() elif not prev: author.num_fix_build += 1 author.save() prev = build.is_good() author.num_build += 1 author.save() return results