{% extends "projects/base.html" %} {% import "site_shell/_macros.html" as ui %} {% block title %}{{ watch.name }} - Watch - {{ project.name }} - Pychestrate{% endblock %} {% block content %} {% macro event_summary(event) -%} {%- if event.tag is defined and event.tag %}New tag {{ event.tag }} {%- elif event.build_id is defined and event.build_id %}Build #{{ event.build_id }} {{ event.build_status if event.build_status is defined and event.build_status else 'finished' }}{% if event.branch is defined and event.branch %} on {{ event.branch }}{% endif %} {%- elif event.created is defined and event.created %}New branch {{ event.branch }} {%- elif event.branch is defined and event.branch %}New commits on {{ event.branch }} {%- else %}Event{% endif -%} {%- if event.commit_sha is defined and event.commit_sha and event.commit_sha != 'HEAD' %} ({{ event.commit_sha[:10] }}){% endif -%} {%- endmacro %} {% set trigger = watch.trigger_source.value %} {% set sample_status = test_sample.sample_build_status if test_sample.sample_build_status is defined else 'succeeded' %}
Starts when
{{ trigger_labels.get(trigger, trigger) }}
{% if trigger == 'build_completion' %}Build specification{% else %}Repository{% endif %}
{{ watch.source_name }}
Times triggered
{{ watch.trigger_count or 0 }}
Last triggered
{{ watch.last_trigger_time | format_datetime('%Y-%m-%d %H:%M', 'Never') }}

Conditions

{% if trigger != 'repository_tag' %} {% endif %} {% if trigger == 'repository_tag' %} {% endif %} {% if trigger == 'build_completion' %} {% endif %} {% if watch.conditions.file_pattern %} {% endif %}
Branch {% if watch.conditions.branch_pattern %}matches {{ watch.conditions.branch_pattern }}{% else %}any branch{% endif %}
Tag {% if watch.conditions.tag_pattern %}matches {{ watch.conditions.tag_pattern }}{% else %}any tag{% endif %}
Build result {% if watch.conditions.build_status in ('succeeded', 'failed') %}{{ watch.conditions.build_status }}{% else %}succeeded or failed{% endif %}
Changed files match {{ watch.conditions.file_pattern }}
Created {{ watch.created_at | format_datetime('%Y-%m-%d %H:%M:%S') }}
Updated {{ watch.updated_at | format_datetime('%Y-%m-%d %H:%M:%S') }}

Actions ({{ watch.actions|length }})

{% if watch.actions %}
{% for action in watch.actions %} {% endfor %}
Action Target Parameters
{{ action_labels.get(action.action.value, action.action.value) }} {% if action.action.value == 'trigger_build' %} {{ target_names.get('trigger_build:' ~ action.target_id) or ('Build specification #' ~ action.target_id ~ ' (removed)') }} {% elif action.action.value == 'trigger_pipeline' %} {{ target_names.get('trigger_pipeline:' ~ action.target_id) or ('Pipeline #' ~ action.target_id ~ ' (removed)') }} {% elif action.action.value == 'trigger_infra_job' %} {{ target_names.get('trigger_infra_job:' ~ action.target_id) or ('Infrastructure specification #' ~ action.target_id ~ ' (removed)') }} {% elif action.action.value == 'trigger_test_job' %} {{ target_names.get('trigger_test_job:' ~ action.target_id) or ('Test specification #' ~ action.target_id ~ ' (removed)') }} {% elif action.target_id %} #{{ action.target_id }} {% else %} none {% endif %} {% if action.parameters %}{{ action.parameters | tojson }}{% else %}none{% endif %}
{% else %} {{ ui.empty_state("No actions configured. This watch records triggers but runs nothing.") }} {% endif %}
{% if can_manage %}

Test this watch

Check a sample event against the conditions. Nothing is run.

{% if trigger == 'repository_tag' %}
{% else %}
{% endif %} {% if trigger == 'build_completion' %}
{% endif %}
{% if test_result %}
{% if test_result.would_trigger %}

Would run This event matches every condition, so the watch would run its {{ test_result.actions_count }} action{{ '' if test_result.actions_count == 1 else 's' }}.

{% elif test_result.conditions_match %}

Would not run The event matches, but the watch is disabled.

{% else %}

Would not run The event does not match every condition.

{% endif %}
{% for key, label in [('branch_pattern', 'Branch'), ('tag_pattern', 'Tag'), ('build_status', 'Build result')] %} {% set outcome = test_result.condition_results[key] %} {% if outcome.applies %} {% endif %} {% endfor %}
Condition Requires Sample Result
{{ label }} {% if key == 'build_status' %}{{ outcome.pattern }}{% else %}matches {{ outcome.pattern }}{% endif %} {{ outcome.value or '(empty)' }} {% if outcome.matches %}matches{% else %}does not match{% endif %}
{% if not (test_result.condition_results.branch_pattern.applies or test_result.condition_results.tag_pattern.applies or test_result.condition_results.build_status.applies) %}

This watch has no conditions. {{ {'repository_commit': 'Every new commit', 'repository_branch': 'Every new branch', 'repository_tag': 'Every new tag', 'build_completion': 'Every finished build'}.get(trigger, 'Every event') }} starts it.

{% endif %}
{% endif %}
{% endif %}

Recent Triggers

{% if trigger_logs %}
{% for log in trigger_logs %} {% endfor %}
Triggered At Event Actions Result
{{ log.triggered_at | format_datetime('%Y-%m-%d %H:%M:%S') }} {% if log.trigger_event %}{{ event_summary(log.trigger_event) }}{% else %}n/a{% endif %} {% for executed in log.actions_executed %} {% set action_value = executed.action if executed.action is defined else 'action' %}
{{ action_labels.get(action_value, action_value) }}{% if executed.success is defined and executed.success %}{% if executed.result_id is defined and executed.result_id %}: #{{ executed.result_id }} started{% else %}: done{% endif %}{% endif %}
{% else %} none {% endfor %}
{% if log.success %} succeeded {% else %} failed {% if log.error_message %}
{{ log.error_message }}
{% endif %} {% endif %}
{% else %} {% if trigger == 'build_completion' %} {{ ui.empty_state("This watch has not been triggered yet.", hint="It starts when a build of " ~ watch.source_name ~ " finishes.") }} {% else %} {{ ui.empty_state("This watch has not been triggered yet.", hint="It starts when a fetch of " ~ watch.source_name ~ " finds a matching change: use Fetch on the repository's page.") }} {% endif %} {% endif %}
{% if can_delete %}
{% endif %} {% endblock %}