def hook(): if request.headers.get('X-Gogs-Signature') != config.SIGNATURE: return {'error': 'invalid signature'}, 400 try: event = request.get_json() except Exception as err: return {'error': str(err)}, 400 commits = sorted(event['commits'], key=to_maya, reverse=True) commit = commits[0] job = Job(repository=event['repository']['full_name'], ssh_url=event['repository']['ssh_url'], clone_url=event['repository']['clone_url'], commit_id=commit['id'], commit_msg=commit['message'], commit_url=commit['url'], author='{name} <{email}>'.format(**commit['author']), committer='{name} <{email}>'.format(**commit['committer']), datetime=to_maya(commit).datetime()) job.run(db.get()) return make_response(jsonify({'id': job.id}), 201)
def detail(jid): database = db.get() job = database.jobs(jid) if job is None: abort(404) return render_template('detail.html', job=serialize_job(job))
def index(status): database = db.get() if status == 'all': filter = database.jobs else: filter = database.jobs.status == getattr(JobStatus, status.upper()) return render_template('index.html', jobs=fetch_jobs(database, filter), active=status)
def detail(jid): database = db.get() return make_response( jsonify({'jobs': list(fetch(database, database.jobs.id == jid))}))
def succeed(): return fetch_status(db.get(), JobStatus.SUCCEED)
def failed(): return fetch_status(db.get(), JobStatus.FAILED)
def errored(): return fetch_status(db.get(), JobStatus.ERRORED)
def started(): return fetch_status(db.get(), JobStatus.STARTED)
def pending(): return fetch_status(db.get(), JobStatus.PENDING)
def index(): database = db.get() return make_response( jsonify({'jobs': list(fetch(database, database.jobs))}))