Exemplo n.º 1
0
def index():
    """All jobs."""
    jenkins_url = app.config['custom']['jenkins']['url']
    query_str = request.args.to_dict()
    query_s = request.args.to_dict()
    if 'query' in query_str:
        query_str = eval(query_str['query'])
        jobs = Job.find(query_str=query_str, projection=PROJECTION)
    else:
        jobs = Job.find(projection=PROJECTION)
    form = Dummy()
    statuses = Counter([
        job['last_build']['status'] for job in jobs
        if 'status' in job['last_build']
    ])
    releases = Counter([
        job['release'] for job in jobs if 'release' in job and job['release']
    ])
    testers = Counter(
        [job['tester'] for job in jobs if 'tester' in job and job['tester']])
    if "query" in query_s:
        query_string = query_s['query']
    else:
        query_string = query_s
    return render_template('jobs/index.html',
                           jenkins_url=jenkins_url,
                           query_str=query_string,
                           releases=dict(releases),
                           statuses=dict(statuses),
                           testers=dict(testers),
                           form=form)
Exemplo n.º 2
0
 def remove_jobs(self, jenkins_jobs):
     """Removes jobs from the database based on the list of jobs
     in Jenkins.
     """
     for job in Job.find():
         if job['name'] not in jenkins_jobs:
             Job.delete_one(job['name'])
             LOG.info("Deleted job: %s" % job['name'])
Exemplo n.º 3
0
def jenkins_update():
    """Handles update received from Jenkins."""
    json = request.get_json(silent=True)
    if not len(Job.find(name=json['name'])):
        JenkinsAgent.classify_and_insert_to_db(json)
    else:
        build = adjust_build_data(json['build'])
        Job.update_build(job_name=json['name'], build=build)
    return jsonify({'notification': 'UPDATE_COMPLETE'})
Exemplo n.º 4
0
def get_builds(job_name=None):
    """Return builds"""
    results = {'data': []}
    jobs = Job.find(name=job_name, exact_match=True)
    for job in jobs:
        for build in job['builds']:
            build['job_name'] = job['name']
            results['data'].append(build)
    return jsonify(results)
Exemplo n.º 5
0
def all_builds():
    """All builds API route."""
    results = {'data': []}
    jobs = Job.find()
    for job in jobs:
        for build in job['builds']:
            build['job_name'] = job['name']
            results['data'].append(build)
    return jsonify(results)
Exemplo n.º 6
0
def jobs(query_str=None):
    """All jobs API route."""
    q_str = request.args.get('query_str', default={})
    if q_str:
        query_str = eval(q_str)
    else:
        query_str = {}
    results = {'data': Job.find(query_str=query_str, projection=PROJECTION)}
    return jsonify(results)
Exemplo n.º 7
0
def all_tests():
    """All builds API route."""
    results = {'data': []}
    jobs = Job.find()
    for job in jobs:
        for build in job['builds']:
            if 'tests' in build:
                for test in build['tests']:
                    results['data'].append(test)
    return jsonify(results)
Exemplo n.º 8
0
def build(name, number):
    """Specific build summary."""
    uf = url_for('api.get_tests', job_name=name, build_number=number)
    entity = Job.find(name, build_number=int(number),
                      exact_match=True,
                      projection={"builds.$": 1, "_id": 0})
    entity_json = json.dumps(entity, indent=4, sort_keys=True,
                             default=json_util.default)
    jenkins_url = app.config['custom']['jenkins']['url']
    return render_template('builds/one_build_summary.html', job_name=name,
                           uf=uf, jenkins_url=jenkins_url, build_num=number,
                           entity_json=entity_json)
Exemplo n.º 9
0
def get_jobs(DFG_name=None,
             squad_name=None,
             component_name=None,
             job_name=None):
    """Returns jobs."""
    results = {'data': []}
    if squad_name:
        jobs = Job.find(squad=squad_name, projection=PROJECTION)
    elif component_name:
        jobs = Job.find(query_str={
            'DFG': DFG_name,
            'component': component_name
        },
                        projection=PROJECTION)
    elif DFG_name:
        jobs = Job.find(name='DFG-{}'.format(DFG_name), projection=PROJECTION)
    elif job_name:
        jobs = Job.find(name=job_name, exact_match=True, projection=PROJECTION)
    for job in jobs:
        results['data'].append(job)
    return jsonify(results)
Exemplo n.º 10
0
def job(name):
    """Specific job summary."""
    uf = url_for('api.get_builds', job_name=name)
    job = Job.find(name=name)
    job[0].pop('_id')
    entity_json = json.dumps(job,
                             indent=4,
                             sort_keys=True,
                             default=json_util.default)
    jenkins_url = app.config['custom']['jenkins']['url']
    return render_template('jobs/one_job_summary.html',
                           job_name=name,
                           uf=uf,
                           jenkins_url=jenkins_url,
                           entity_json=entity_json)
Exemplo n.º 11
0
def get_tests(job_name=None, build_number=None):
    """Return builds"""
    results = {'data': []}
    job = Job.find(job_name,
                   build_number=int(build_number),
                   exact_match=True,
                   projection={
                       'builds.$.tests': 1,
                       '_id': 0
                   })
    if 'tests' in job[0]['builds'][0]:
        tests = job[0]['builds'][0]['tests']
    else:
        tests = load_tests(job=job_name, build=build_number)
    results = {'data': tests}
    return jsonify(results)