WebHook broker that accepts notifications from multiple platforms and performs simple actions in response
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

jenkins.py 986B

1234567891011121314151617181920212223242526272829303132333435
  1. import os
  2. import jenkins
  3. from bs4 import BeautifulSoup
  4. from .service import Service
  5. class Jenkins(Service):
  6. SCM_CLASS = "hudson.plugins.git.GitSCM"
  7. def __init__(self, url, username, password):
  8. self._server = jenkins.Jenkins(url, username=username, password=password)
  9. def get_jobs(self):
  10. for job in self._server.get_all_jobs():
  11. name = job["fullname"]
  12. config = BeautifulSoup(self._server.get_job_config(name), features="xml")
  13. for git_config in config.find_all("scm", class_=self.SCM_CLASS):
  14. branch_spec = git_config.find("branches").find("name").text
  15. yield name, branch_spec, git_config.find("url").text
  16. def build_job(self, name):
  17. self._server.build_job(name)
  18. def jenkins_factory():
  19. return Jenkins(
  20. os.environ["LAS_JENKINS_URL"],
  21. os.environ["LAS_JENKINS_USER"],
  22. os.environ["LAS_JENKINS_PASSWORD"],
  23. )
  24. Service.add_factory(jenkins_factory)