| |
@@ -16,10 +16,11 @@
|
| |
from pagure.lib.model import BASE, Project
|
| |
from pagure import get_repo_path
|
| |
from pagure import APP, SESSION
|
| |
+ from pagure.exceptions import ConfigNotFound
|
| |
|
| |
|
| |
class PagureCI(BASE):
|
| |
-
|
| |
+ ''' Table for Pagure CI. '''
|
| |
__tablename__ = 'hook_pagure_ci'
|
| |
|
| |
id = sa.Column(sa.Integer, primary_key=True)
|
| |
@@ -34,7 +35,6 @@
|
| |
|
| |
active = sa.Column(sa.Boolean, nullable=False, default=False)
|
| |
display_name = sa.Column(sa.String(64), nullable=False, default='Jenkins')
|
| |
- pagure_name = sa.Column(sa.String(255))
|
| |
|
| |
jenkins_name = sa.Column(sa.String(255))
|
| |
jenkins_url = sa.Column(sa.String(255), nullable=False,
|
| |
@@ -54,20 +54,21 @@
|
| |
self.pagure_ci_token = uuid.uuid4().hex
|
| |
|
| |
|
| |
- class ConfigNotFound(Exception):
|
| |
- pass
|
| |
-
|
| |
-
|
| |
class Service(object):
|
| |
- PAGURE = PagureCI.pagure_name
|
| |
- JENKINS = PagureCI.jenkins_name
|
| |
+ ''' Service to provide project name on pagure and jenkins. '''
|
| |
+ JENKINS = None
|
| |
+ PAGURE = None
|
| |
+ def __init__(self):
|
| |
+ self.PAGURE = SESSION.query(Project).filter(
|
| |
+ Project.id == PagureCI.project_id).first().name
|
| |
+ self.JENKINS = PagureCI.jenkins_name
|
| |
|
| |
|
| |
def get_configs(project_name, service):
|
| |
- """Returns all configurations with given name on a service.
|
| |
+ ''' Returns all configurations with given name on a service.
|
| |
|
| |
:raises ConfigNotFound: when no configuration matches
|
| |
- """
|
| |
+ '''
|
| |
cfg = SESSION.query(PagureCI).filter(
|
| |
service == project_name).all()
|
| |
if not cfg:
|
| |
@@ -76,12 +77,7 @@
|
| |
|
| |
|
| |
class JenkinsForm(wtf.Form):
|
| |
-
|
| |
- '''Form to configure Jenkins hook'''
|
| |
-
|
| |
- pagure_name = TextField('Name of project in Pagure',
|
| |
- [validators.Required(),
|
| |
- validators.Length(max=255)])
|
| |
+ ''' Form to configure Jenkins hook. '''
|
| |
|
| |
jenkins_name = TextField('Name of project in Jenkins',
|
| |
[validators.Required(),
|
| |
@@ -99,7 +95,7 @@
|
| |
|
| |
|
| |
class PagureCiHook(BaseHook):
|
| |
- ''' Jenkins hooks. '''
|
| |
+ ''' Pagure CI hook. '''
|
| |
|
| |
name = 'Pagure CI'
|
| |
description = 'This hook help to set up CI for the project'\
|
| |
@@ -107,10 +103,7 @@
|
| |
form = JenkinsForm
|
| |
db_object = PagureCI
|
| |
backref = 'hook_pagure_ci'
|
| |
- form_fields = [
|
| |
- 'pagure_name', 'jenkins_name',
|
| |
- 'jenkins_url', 'jenkins_token', 'active'
|
| |
- ]
|
| |
+ form_fields = ['jenkins_name', 'jenkins_url', 'jenkins_token', 'active']
|
| |
|
| |
@classmethod
|
| |
def set_up(cls, project):
|
| |
@pingou sorry I rebased. I guess I can't directly use PagureCI.project. Since I need to have an object of PagureCI for which I need to pass. I tried it though but may be I don't know how to use it and hence I opted for this method.