Job-Scheduling in Semaphore ermöglicht die zeitbasierte Automatisierung von Playbook-Ausführungen ohne manuelle Intervention. Dies ist essentiell für wiederkehrende Wartungsaufgaben, Backups und regelmäßige Systemüberprüfungen.
Scheduling-Engine:
Semaphore Scheduler:
├── Cron-Parser: Verarbeitung von Cron-Expressions
├── Job-Queue: Warteschlange für geplante Jobs
├── Execution-Engine: Ausführung zum geplanten Zeitpunkt
├── Conflict-Resolution: Behandlung überlappender Jobs
└── Failure-Handling: Retry-Logik und Fehlerbehandlung
Schedule-Einstellungen:
Template: "Daily System Backup"
├── Schedule: Enabled
├── Cron Expression: "0 2 * * *"
├── Timezone: Europe/Berlin
├── Max Parallel: 1
├── Retry Policy: 3 attempts
└── Timeout: 4 hours
Cron-Feldstruktur:
┌───────────── Minute (0-59)
│ ┌─────────── Hour (0-23)
│ │ ┌───────── Day of Month (1-31)
│ │ │ ┌─────── Month (1-12)
│ │ │ │ ┌───── Day of Week (0-7, Sunday = 0 or 7)
│ │ │ │ │
* * * * *
Häufige Scheduling-Pattern:
# Täglich um 2:00 Uhr
0 2 * * *
# Jeden Sonntag um 3:30 Uhr
30 3 * * 0
# Werktags um 8:00 und 18:00 Uhr
0 8,18 * * 1-5
# Alle 15 Minuten
*/15 * * * *
# Jeden ersten Tag des Monats um Mitternacht
0 0 1 * *
# Alle 6 Stunden
0 */6 * * *
# Montag bis Freitag um 9:00 Uhr
0 9 * * 1-5Komplexe Zeitpläne:
# Alle 2 Stunden zwischen 8:00 und 18:00 Uhr, werktags
0 8-18/2 * * 1-5
# Jeden 15. und letzten Tag des Monats
0 12 15,L * *
# Jeden zweiten Mittwoch
0 14 * * 3#2
# Quartalsmäßig (Januar, April, Juli, Oktober)
0 6 1 1,4,7,10 *Gestaffeltes Backup-System:
Backup Schedule Matrix:
├── Inkrementelle Backups
│ ├── Expression: "0 1 * * 1-6"
│ ├── Frequency: Täglich außer Sonntag
│ └── Duration: ~30 Minuten
├── Vollbackups
│ ├── Expression: "0 2 * * 0"
│ ├── Frequency: Sonntags
│ └── Duration: ~4 Stunden
└── Archivierung
├── Expression: "0 4 1 * *"
├── Frequency: Monatlich
└── Duration: ~2 Stunden
Koordinierte Systemwartung:
Maintenance Window: "Monthly Patching"
├── Pre-Maintenance Checks
│ ├── Schedule: "0 20 * * 6" # Samstag 20:00
│ ├── Tasks: System validation, backup verification
│ └── Duration: 1 Stunde
├── System Patching
│ ├── Schedule: "0 2 * * 0" # Sonntag 02:00
│ ├── Tasks: Package updates, security patches
│ └── Duration: 3 Stunden
└── Post-Maintenance Validation
├── Schedule: "0 6 * * 0" # Sonntag 06:00
├── Tasks: Service verification, health checks
└── Duration: 1 Stunde
Globale Timezone-Einstellungen:
{
"default_timezone": "Europe/Berlin",
"supported_timezones": [
"UTC",
"Europe/Berlin",
"Europe/London",
"America/New_York",
"America/Los_Angeles",
"Asia/Tokyo"
]
}Multi-Region-Scheduling:
Template: "Global Infrastructure Monitoring"
├── Europe Region
│ ├── Schedule: "0 3 * * *"
│ ├── Timezone: Europe/Berlin
│ └── Target: European data centers
├── US East Region
│ ├── Schedule: "0 3 * * *"
│ ├── Timezone: America/New_York
│ └── Target: US East data centers
└── Asia Pacific Region
├── Schedule: "0 3 * * *"
├── Timezone: Asia/Tokyo
└── Target: APAC data centers
Overlap-Prevention-Strategien:
Execution Policy Options:
├── Skip if Running
│ ├── Behavior: Neue Ausführung wird übersprungen
│ ├── Use Case: Backup-Jobs, lange laufende Tasks
│ └── Risk: Verpasste Ausführungen
├── Queue if Running
│ ├── Behavior: Job wird in Warteschlange eingereiht
│ ├── Use Case: Kritische, sequentielle Tasks
│ └── Risk: Aufstauende Warteschlange
├── Kill and Restart
│ ├── Behavior: Laufender Job wird beendet
│ ├── Use Case: Monitoring, Health Checks
│ └── Risk: Unvollständige Operationen
└── Parallel Execution
├── Behavior: Multiple Instanzen erlaubt
├── Use Case: Unabhängige, parallelisierbare Tasks
└── Risk: Ressourcenkonflikte
Pipeline-Workflows ermöglichen die Orchestrierung komplexer, mehrstufiger Automatisierungsprozesse mit definierten Abhängigkeiten und Bedingungen zwischen einzelnen Jobs.
Workflow-Struktur:
CI/CD Pipeline Example:
├── Stage 1: Pre-Deployment
│ ├── Code Quality Check
│ ├── Security Scan
│ └── Dependency Validation
├── Stage 2: Build & Test
│ ├── Application Build (depends on Stage 1)
│ ├── Unit Tests (parallel to Build)
│ └── Integration Tests (depends on Build)
├── Stage 3: Staging Deployment
│ ├── Deploy to Staging (depends on Stage 2)
│ ├── Smoke Tests (depends on Deploy)
│ └── Performance Tests (parallel to Smoke Tests)
└── Stage 4: Production Deployment
├── Blue-Green Switch (depends on Stage 3)
├── Health Verification (depends on Switch)
└── Rollback Capability (conditional)
Dependency-Configuration:
Template: "Application Deployment Pipeline"
├── Job 1: "Pre-Deployment Validation"
│ ├── Dependencies: None (Entry Point)
│ ├── Success Condition: All tasks successful
│ └── Failure Action: Stop pipeline
├── Job 2: "Database Migration"
│ ├── Dependencies: Job 1 (successful)
│ ├── Parallel Execution: False
│ └── Timeout: 30 minutes
├── Job 3: "Application Deployment"
│ ├── Dependencies: Job 2 (successful)
│ ├── Variables: Inherited from Job 2
│ └── Rollback: Job 4 on failure
└── Job 4: "Post-Deployment Tests"
├── Dependencies: Job 3 (successful)
├── Parallel Tests: Health, Performance, Security
└── Report Generation: Always execute
Bedingte Workflow-Ausführung:
# Pipeline-Konfiguration mit Bedingungen
pipeline_stages:
pre_deployment:
condition: always
security_scan:
condition: "{{ environment == 'production' }}"
depends_on: pre_deployment
staging_deployment:
condition: "{{ branch == 'main' and security_scan.status == 'success' }}"
depends_on: [pre_deployment, security_scan]
production_deployment:
condition: "{{ staging_deployment.status == 'success' and manual_approval == true }}"
depends_on: staging_deployment
manual_trigger: requiredParallele Job-Ausführung:
Parallel Processing Pipeline:
├── Data Processing Branch 1
│ ├── Job A1: Extract Data Source 1
│ ├── Job A2: Transform Data 1 (depends on A1)
│ └── Job A3: Load to Warehouse 1 (depends on A2)
├── Data Processing Branch 2
│ ├── Job B1: Extract Data Source 2
│ ├── Job B2: Transform Data 2 (depends on B1)
│ └── Job B3: Load to Warehouse 2 (depends on B2)
└── Convergence Point
├── Job C1: Data Validation (depends on A3, B3)
├── Job C2: Report Generation (depends on C1)
└── Job C3: Notification (depends on C2)
Verteilte Verarbeitung:
# Fan-out Phase: Deployment zu mehreren Umgebungen
fan_out_jobs:
- name: "Deploy to Development"
template: "dev-deployment"
depends_on: "build"
- name: "Deploy to Staging"
template: "staging-deployment"
depends_on: "build"
- name: "Deploy to QA"
template: "qa-deployment"
depends_on: "build"
# Fan-in Phase: Konsolidierung der Ergebnisse
fan_in_jobs:
- name: "Integration Tests"
template: "integration-testing"
depends_on: ["Deploy to Development", "Deploy to Staging", "Deploy to QA"]
- name: "Release Report"
template: "release-reporting"
depends_on: "Integration Tests"Status-Weitergabe zwischen Jobs:
Job Status Handling:
├── Success: Nachfolgende Jobs werden ausgeführt
├── Warning: Pipeline fortsetzung mit Warnung
├── Failure: Pipeline stoppt, Rollback-Jobs werden ausgeführt
├── Timeout: Retry-Logic oder Pipeline-Abbruch
└── Manual Intervention: Pipeline pausiert für Benutzerentscheidung
Status Variables:
├── previous_job_status: "success|warning|failure|timeout"
├── pipeline_health_score: 0-100 (basierend auf Job-Erfolg)
├── execution_context: Übergabe von Variablen zwischen Jobs
└── rollback_required: Boolean flag für Rollback-Initiierung
Datenübertragung zwischen Jobs:
# Job 1: Artefakt-Generierung
- name: Generate deployment package
archive:
path: /app/build/
dest: "/tmp/{{ pipeline_id }}/deployment-{{ version }}.tar.gz"
- name: Store pipeline artifacts
copy:
src: "/tmp/{{ pipeline_id }}/"
dest: "{{ semaphore_artifacts_path }}/{{ pipeline_id }}/"
# Job 2: Artefakt-Nutzung
- name: Retrieve deployment package
unarchive:
src: "{{ semaphore_artifacts_path }}/{{ pipeline_id }}/deployment-{{ version }}.tar.gz"
dest: /opt/application/Event-basierte Trigger ermöglichen automatische Playbook-Ausführungen als Reaktion auf externe Ereignisse, insbesondere Git-Repository-Änderungen.
GitHub Webhook-Konfiguration:
{
"name": "Semaphore CI/CD",
"active": true,
"events": [
"push",
"pull_request",
"create",
"delete"
],
"config": {
"url": "https://semaphore.company.com/api/project/1/webhook/github",
"content_type": "json",
"secret": "webhook-secret-token",
"insecure_ssl": "0"
}
}GitLab Webhook-Setup:
{
"url": "https://semaphore.company.com/api/project/1/webhook/gitlab",
"push_events": true,
"tag_push_events": true,
"merge_requests_events": true,
"wiki_page_events": false,
"deployment_events": true,
"issues_events": false,
"confidential_issues_events": false,
"note_events": false,
"pipeline_events": true,
"wiki_page_events": false,
"enable_ssl_verification": true,
"token": "webhook-verification-token"
}Event-Filter-Konfiguration:
# Webhook Event Processing Rules
webhook_filters:
branch_filters:
include:
- "main"
- "develop"
- "release/*"
- "hotfix/*"
exclude:
- "feature/*"
- "experimental/*"
file_filters:
include_patterns:
- "**.yml"
- "**.yaml"
- "src/**"
- "config/**"
exclude_patterns:
- "**.md"
- "docs/**"
- ".gitignore"
commit_message_filters:
trigger_keywords:
- "[deploy]"
- "[ci]"
- "deploy:"
skip_keywords:
- "[skip ci]"
- "[no deploy]"
- "docs only"Event-zu-Template-Mapping:
Git Events → Semaphore Actions:
├── Push to main branch
│ ├── Trigger: Production Deployment Pipeline
│ ├── Condition: All tests pass
│ └── Approval: Automatic
├── Push to develop branch
│ ├── Trigger: Staging Deployment
│ ├── Condition: Build successful
│ └── Approval: Automatic
├── Pull Request created
│ ├── Trigger: PR Validation Pipeline
│ ├── Condition: Always
│ └── Approval: Automatic
├── Tag created (v*.*)
│ ├── Trigger: Release Deployment
│ ├── Condition: Tag follows semver
│ └── Approval: Manual required
└── Branch deleted
├── Trigger: Cleanup Pipeline
├── Condition: Branch was feature/*
└── Approval: Automatic
Erweiterte Event-Verarbeitung:
# Advanced Webhook Processing
event_processors:
push_processor:
conditions:
- branch: "{{ webhook.ref.split('/')[2] }}"
- modified_files: "{{ webhook.commits | map(attribute='modified') | flatten }}"
- author: "{{ webhook.commits[0].author.email }}"
actions:
- template: "ci-cd-pipeline"
variables:
git_branch: "{{ branch }}"
commit_sha: "{{ webhook.after }}"
trigger_user: "{{ author }}"
pull_request_processor:
conditions:
- action: "{{ webhook.action }}"
- target_branch: "{{ webhook.pull_request.base.ref }}"
- source_branch: "{{ webhook.pull_request.head.ref }}"
actions:
- template: "pr-validation"
condition: "{{ action in ['opened', 'synchronize'] }}"
variables:
pr_number: "{{ webhook.pull_request.number }}"
pr_title: "{{ webhook.pull_request.title }}"GitOps-Pipeline-Struktur:
GitOps Repository Structure:
├── applications/
│ ├── frontend/
│ │ ├── base/
│ │ │ ├── deployment.yml
│ │ │ └── service.yml
│ │ ├── overlays/
│ │ │ ├── staging/
│ │ │ └── production/
│ │ └── .semaphore/
│ │ └── deployment-pipeline.yml
│ └── backend/
│ ├── base/
│ ├── overlays/
│ └── .semaphore/
├── infrastructure/
│ ├── terraform/
│ ├── ansible/
│ └── .semaphore/
│ └── infrastructure-pipeline.yml
└── global/
├── monitoring/
├── logging/
└── .semaphore/
Branch-basierte Deployment-Strategien:
# GitOps Deployment Matrix
deployment_strategies:
feature_branches:
strategy: "ephemeral_environment"
trigger: "push"
environment: "feature-{{ branch_name | regex_replace('/', '-') }}"
cleanup: "on_branch_delete"
develop_branch:
strategy: "rolling_deployment"
trigger: "push"
environment: "staging"
tests: ["unit", "integration", "e2e"]
main_branch:
strategy: "blue_green_deployment"
trigger: "push"
environment: "production"
approval: "manual"
rollback: "automatic_on_failure"
release_tags:
strategy: "canary_deployment"
trigger: "tag_push"
environment: "production"
canary_percentage: 10
promotion_criteria:
- error_rate: "<0.1%"
- response_time: "<500ms"
- duration: "30m"E-Mail-Notifications bieten zuverlässige Benachrichtigungen über Job-Status, Pipeline-Ergebnisse und System-Events.
E-Mail-Server-Setup:
{
"email_sender": "semaphore@company.com",
"email_host": "smtp.company.com",
"email_port": "587",
"email_secure": true,
"email_username": "semaphore-notifications",
"email_password": "[credential reference]",
"email_from_name": "Semaphore Automation",
"email_reply_to": "noreply@company.com"
}E-Mail-Trigger-Konfiguration:
Notification Triggers:
├── Job Success
│ ├── Condition: Job completed successfully
│ ├── Recipients: Job owner, project team
│ └── Frequency: Always
├── Job Failure
│ ├── Condition: Job failed or timed out
│ ├── Recipients: Job owner, on-call team, project admins
│ └── Frequency: Always
├── Pipeline Completion
│ ├── Condition: All pipeline jobs completed
│ ├── Recipients: Release manager, stakeholders
│ └── Frequency: Success and failure
├── Security Alert
│ ├── Condition: Security-related job failures
│ ├── Recipients: Security team, project owner
│ └── Frequency: Always
└── System Events
├── Condition: Repository sync errors, credential expiry
├── Recipients: System administrators
└── Frequency: Always
Anpassbare Benachrichtigungs-Templates:
<!-- Job Failure Email Template -->
<html>
<head>
<title>Job Failure: {{ job.template.name }}</title>
</head>
<body>
<h2>❌ Job Failed: {{ job.template.name }}</h2>
<table>
<tr><td><strong>Project:</strong></td><td>{{ job.project.name }}</td></tr>
<tr><td><strong>Template:</strong></td><td>{{ job.template.name }}</td></tr>
<tr><td><strong>Started:</strong></td><td>{{ job.start_time }}</td></tr>
<tr><td><strong>Duration:</strong></td><td>{{ job.duration }}</td></tr>
<tr><td><strong>User:</strong></td><td>{{ job.user.name }}</td></tr>
</table>
<h3>Error Summary:</h3>
<pre>{{ job.error_summary }}</pre>
<p><a href="{{ semaphore_url }}/project/{{ job.project.id }}/history/{{ job.id }}">
View Job Details
</a></p>
</body>
</html>Slack-Bot-Setup:
{
"slack_enabled": true,
"slack_webhook_url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
"slack_channel": "#deployments",
"slack_username": "Semaphore Bot",
"slack_icon_emoji": ":robot_face:",
"slack_mention_users": ["@devops-team"],
"slack_thread_replies": true
}Rich Message-Format:
{
"text": "Job Status Update",
"attachments": [
{
"color": "danger",
"fallback": "Job Failed: Frontend Deployment",
"title": "❌ Job Failed: Frontend Deployment",
"title_link": "https://semaphore.company.com/project/1/history/1234",
"fields": [
{
"title": "Project",
"value": "E-Commerce Frontend",
"short": true
},
{
"title": "Duration",
"value": "15m 32s",
"short": true
},
{
"title": "Branch",
"value": "main",
"short": true
},
{
"title": "User",
"value": "@john.doe",
"short": true
}
],
"actions": [
{
"type": "button",
"text": "View Logs",
"url": "https://semaphore.company.com/project/1/history/1234"
},
{
"type": "button",
"text": "Retry Job",
"url": "https://semaphore.company.com/project/1/templates/5"
}
],
"footer": "Semaphore",
"ts": 1692364800
}
]
}Kontext-sensitive Benachrichtigungen:
# Slack Notification Rules
slack_notification_rules:
production_deployments:
channels: ["#production-alerts", "#leadership"]
mention_users: ["@devops-oncall", "@release-manager"]
message_priority: "high"
include_fields: ["duration", "commit_info", "test_results"]
staging_deployments:
channels: ["#staging-updates"]
mention_users: ["@dev-team"]
message_priority: "normal"
thread_notifications: true
failed_jobs:
channels: ["#alerts"]
mention_users: ["@{{ job.user.slack_handle }}"]
message_priority: "urgent"
include_error_logs: true
max_log_lines: 50
security_scans:
channels: ["#security-alerts"]
mention_users: ["@security-team"]
message_priority: "critical"
include_vulnerability_summary: trueWebhook-Payload-Definition:
{
"event_type": "job_completed",
"timestamp": "2024-08-18T14:30:00Z",
"semaphore": {
"version": "2.8.0",
"instance": "https://semaphore.company.com"
},
"project": {
"id": 1,
"name": "E-Commerce Platform",
"repository": "git@github.com:company/ecommerce.git"
},
"job": {
"id": 1234,
"template_id": 5,
"template_name": "Production Deployment",
"status": "success",
"start_time": "2024-08-18T14:15:00Z",
"end_time": "2024-08-18T14:30:00Z",
"duration": 900,
"user": {
"id": 10,
"name": "John Doe",
"email": "john.doe@company.com"
},
"environment": {
"git_branch": "main",
"git_commit": "a1b2c3d4e5f6789",
"deployment_environment": "production"
}
},
"metrics": {
"tasks_total": 25,
"tasks_successful": 25,
"tasks_failed": 0,
"tasks_skipped": 0
}
}Integration mit externen Systemen:
Webhook Integrations:
├── ITSM-Systeme (ServiceNow, Jira Service Management)
│ ├── Incident-Erstellung bei kritischen Fehlern
│ ├── Change-Request-Updates bei Deployments
│ └── Automatische Ticket-Schließung bei Erfolg
├── Monitoring-Systeme (Prometheus, DataDog)
│ ├── Custom Metrics für Deployment-Häufigkeit
│ ├── Alert-Integration für Failed Deployments
│ └── Performance-Metriken für Job-Laufzeiten
├── Chat-Systeme (Microsoft Teams, Discord)
│ ├── Deployment-Ankündigungen
│ ├── Failure-Notifications
│ └── Status-Dashboard-Updates
└── Security-Tools (SIEM, Vulnerability Scanners)
├── Security-Scan-Ergebnisse
├── Compliance-Berichte
└── Audit-Trail-Daten
Hierarchische Benachrichtigung:
# Escalation Rules
escalation_policies:
critical_production_failure:
level_1:
delay: "0m"
recipients: ["on-call-engineer"]
channels: ["slack", "sms"]
level_2:
delay: "15m"
condition: "no_acknowledgment"
recipients: ["team-lead", "on-call-engineer"]
channels: ["slack", "email", "phone"]
level_3:
delay: "30m"
condition: "no_resolution"
recipients: ["department-manager", "cto"]
channels: ["email", "phone"]
additional_actions: ["create_incident", "page_executives"]
standard_job_failure:
level_1:
delay: "0m"
recipients: ["job-owner"]
channels: ["slack", "email"]
level_2:
delay: "2h"
condition: "no_acknowledgment"
recipients: ["team-members"]
channels: ["slack"]
security_alert:
level_1:
delay: "0m"
recipients: ["security-team"]
channels: ["slack", "email", "security-portal"]
priority: "P1"
level_2:
delay: "5m"
condition: "always"
recipients: ["ciso", "security-manager"]
channels: ["email", "phone"]
additional_actions: ["create_security_incident"]Notification-Performance-Tracking:
Notification Metrics:
├── Delivery Success Rate
│ ├── Email: 99.2%
│ ├── Slack: 99.8%
│ ├── Webhooks: 98.5%
│ └── SMS: 97.1%
├── Response Times
│ ├── Average Acknowledgment: 4.2 minutes
│ ├── P1 Incidents: 1.8 minutes
│ ├── Standard Alerts: 8.5 minutes
│ └── Non-critical: 45 minutes
├── Escalation Statistics
│ ├── Level 1 Resolution: 85%
│ ├── Level 2 Escalation: 12%
│ ├── Level 3 Escalation: 3%
│ └── Unresolved: <1%
└── Notification Volume
├── Daily Average: 245 notifications
├── Peak Hours: 08:00-10:00, 14:00-16:00
├── False Positives: 2.3%
└── Critical Alerts: 1.8% of total
Smart Notification-Filtering:
# Intelligent Notification Filtering
notification_filters:
noise_reduction:
duplicate_suppression:
window: "15m"
max_duplicates: 3
key_fields: ["template_id", "error_type"]
similar_failure_grouping:
window: "1h"
similarity_threshold: 0.8
group_notifications: true
maintenance_window_suppression:
active_windows: ["scheduled_maintenance"]
suppress_types: ["job_failure", "system_alert"]
exceptions: ["security_alert", "critical_failure"]
smart_routing:
business_hours:
weekdays: "08:00-18:00"
timezone: "Europe/Berlin"
reduced_escalation: true
severity_based_routing:
critical: ["immediate_notification", "phone_call"]
high: ["slack", "email", "sms_if_no_ack"]
medium: ["slack", "email_digest"]
low: ["daily_summary", "weekly_report"]
personalization:
user_preferences:
quiet_hours: "22:00-06:00"
preferred_channels: ["slack", "email"]
notification_frequency: "immediate"
digest_schedule: "daily_summary_at_09:00"