From dd6f039b2f02dfba76e793a66ce741c31f8a1c8d Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Mar 26 2018 06:43:14 +0000 Subject: Update documentation and DB update Use the current value of the active CI hook to update the active_pr value. Also add documentation for new PR/Commit activation option. Signed-off-by: Clement Verna --- diff --git a/alembic/versions/eab41ce5f92a_add_active_commit_attribute_to_the_hook_.py b/alembic/versions/eab41ce5f92a_add_active_commit_attribute_to_the_hook_.py index 69a970a..373642c 100644 --- a/alembic/versions/eab41ce5f92a_add_active_commit_attribute_to_the_hook_.py +++ b/alembic/versions/eab41ce5f92a_add_active_commit_attribute_to_the_hook_.py @@ -24,9 +24,19 @@ def upgrade(): 'hook_pagure_ci', sa.Column('active_pr', sa.Boolean, nullable=True, default=False) ) + op.execute('UPDATE hook_pagure_ci SET active_pr=active') + op.execute('UPDATE hook_pagure_ci SET active_commit=False') + op.alter_column( + 'hook_pagure_ci', 'active_pr', + nullable=False, existing_nullable=True) + op.alter_column( + 'hook_pagure_ci', 'active_commit', + nullable=False, existing_nullable=True) def downgrade(): ''' Revert the active_commit column added''' + + op.execute('UPDATE hook_pagure_ci SET active=active_pr') op.drop_column('hook_pagure_ci', 'active_commit') - op.drop_column('hook_pagure_ci', 'active_pr') \ No newline at end of file + op.drop_column('hook_pagure_ci', 'active_pr') diff --git a/doc/usage/pagure_ci_jenkins.rst b/doc/usage/pagure_ci_jenkins.rst index 3922be8..81680bc 100644 --- a/doc/usage/pagure_ci_jenkins.rst +++ b/doc/usage/pagure_ci_jenkins.rst @@ -16,11 +16,12 @@ How to enable Pagure CI * Select the type of CI service you want -* Enter the URL to the project on the CI service. For example, if your - project is running at `http://jenkins.fedoraproject.org` you will need to - enter the URL: `http://jenkins.fedoraproject.org/job/` +* Enter the URL of the CI service. For example `http://jenkins.fedoraproject.org` -* Tick the checkbox activating the hook. +* Enter the name of the job the CI service will trigger. For example `pagure-ci` + +* Tick the checkbox activating the hook. Either trigger on every commits, trigger only +on pull-requests or both every commits and pull-requests. These steps will activate the hook, after reloading the page or the tab, you diff --git a/pagure/hooks/pagure_ci.py b/pagure/hooks/pagure_ci.py index 29d1a2a..0666723 100644 --- a/pagure/hooks/pagure_ci.py +++ b/pagure/hooks/pagure_ci.py @@ -112,6 +112,10 @@ class PagureCiForm(FlaskForm): wtforms.validators.Length(max=255)], ) + # The active field is not render in the UI it used + # to hold the result of a logical OR between active_pr + # and active_commit. + # The value of active is set in pagure.ui.plugins.view_plugin active = wtforms.BooleanField( 'Activate Pagure CI service', [wtforms.validators.Optional()] diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py index 656e125..5f64bc9 100644 --- a/pagure/ui/plugins.py +++ b/pagure/ui/plugins.py @@ -134,7 +134,7 @@ def view_plugin(repo, plugin, username=None, namespace=None, full=True): # Compute the ci_hook active value in function # of the active PR and active commit values. - if form.active_pr and form.active_commit: + if hasattr(form, 'active_pr') and hasattr(form, 'active_commit'): if form.active_pr.data or form.active_commit.data: form.active.data = True