mirror of
https://github.com/lubuntu-team/lugito.git
synced 2025-05-01 21:11:28 +00:00
Add Jenkins nagging to Lugito
Test Plan: Deploy I guess? Reviewers: wxl, teward, apt-ghetto Reviewed By: teward, apt-ghetto Subscribers: apt-ghetto, #development_team Tags: #development_team Differential Revision: https://phab.lubuntu.me/D93
This commit is contained in:
parent
9820ddb26b
commit
9b4358ed98
@ -16,6 +16,9 @@ import logging
|
|||||||
import phabricator
|
import phabricator
|
||||||
import lugito
|
import lugito
|
||||||
import requests
|
import requests
|
||||||
|
import json
|
||||||
|
import jenkinsapi.custom_exceptions
|
||||||
|
from jenkinsapi.jenkins import Jenkins
|
||||||
from string import Template
|
from string import Template
|
||||||
|
|
||||||
|
|
||||||
@ -88,5 +91,46 @@ class jenkins(object):
|
|||||||
r.status_code, r.reason))
|
r.status_code, r.reason))
|
||||||
|
|
||||||
|
|
||||||
|
def auth_jenkins(self):
|
||||||
|
"""Authenticate with the Jenkins server"""
|
||||||
|
|
||||||
|
site = lugito.config.CONFIG["connectors"]["jenkins"]["site"]
|
||||||
|
user = lugito.config.CONFIG["connectors"]["jenkins"]["user"]
|
||||||
|
key = lugito.config.CONFIG["connectors"]["jenkins"]["api_key"]
|
||||||
|
|
||||||
|
server = Jenkins(site, username=user, password=key)
|
||||||
|
|
||||||
|
return server
|
||||||
|
|
||||||
|
|
||||||
|
def receive(self, proj_name):
|
||||||
|
"""Receive the project name and return the status of the last build"""
|
||||||
|
|
||||||
|
proj_name = json.loads(proj_name)["PROJECT"]
|
||||||
|
|
||||||
|
status = None
|
||||||
|
|
||||||
|
# Authenticate with the server
|
||||||
|
jenkins = self.auth_jenkins()
|
||||||
|
|
||||||
|
# Check if the project name matches a valid one on the server
|
||||||
|
# If it does, grab the job info, if it doesn't, stop
|
||||||
|
proj = None
|
||||||
|
for job in jenkins.get_jobs():
|
||||||
|
if job[0] == proj_name:
|
||||||
|
proj = job
|
||||||
|
|
||||||
|
if not proj:
|
||||||
|
return status
|
||||||
|
|
||||||
|
# Return the status of the last completed build
|
||||||
|
try:
|
||||||
|
status = proj[1].get_last_completed_build().get_status()
|
||||||
|
url = proj[1].get_last_completed_build().get_build_url()
|
||||||
|
return proj[0], status, url
|
||||||
|
except jenkinsapi.custom_exceptions.NoBuildData:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def listen(self):
|
def listen(self):
|
||||||
pass
|
pass
|
||||||
|
@ -189,6 +189,17 @@ def jenkinstrigger():
|
|||||||
return 'Ok'
|
return 'Ok'
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/jenkinsnag", methods=["POST"])
|
||||||
|
def jenkinsircnotify():
|
||||||
|
"""Jenkins IRC notifications"""
|
||||||
|
|
||||||
|
# Get the status of the most recent build to the given project
|
||||||
|
proj, status, link = jenkins_con.receive(request.data)
|
||||||
|
|
||||||
|
if status:
|
||||||
|
irc_con.send("Lubuntu CI", proj, status, link)
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
irc_con.connect()
|
irc_con.connect()
|
||||||
launchpad_con.connect()
|
launchpad_con.connect()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user