DEV Community

Cover image for How to Add AI to Your Existing CI/CD Pipeline
Swrly
Swrly

Posted on • Originally published at swrly.com

How to Add AI to Your Existing CI/CD Pipeline

The worst way to add AI to your CI/CD pipeline is to rip out what works and replace it with something new. Your deploy scripts are battle-tested. Your GitHub Actions have survived production incidents. Your Jenkins pipelines have years of accumulated fixes for edge cases you have forgotten about.

You do not need to replace any of that. You need to plug AI workflows into the gaps -- the parts where human judgment is the bottleneck and the context-gathering is the toil.

Swrly is designed to sit alongside your existing CI/CD system, not replace it. Here is how the three trigger types work in practice.

The Integration Problem

Most AI-in-CI proposals fail because they assume you are starting from scratch. "Just add this agent framework to your pipeline" means rewriting your pipeline in a new framework's DSL. Nobody wants to do that, and nobody should.

What you actually want is a way to say: "After this deploy step, run an AI workflow that does X, and send the results to Y." Your CI/CD system handles the deploy. The AI handles the analysis. Neither needs to know much about the other.

Swrly's trigger system is built for this exact pattern. Three trigger types matter for CI/CD integration: webhooks, API triggers, and event triggers.

Webhook Triggers

Webhook triggers are the simplest integration point. Your CI/CD system sends a POST request to a Swrly webhook URL, and a workflow starts.

GitHub Actions example. Add a step at the end of your deploy job that fires a webhook:

# .github/workflows/deploy.yml
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to production
        run: ./scripts/deploy.sh

      - name: Trigger post-deploy review
        if: success()
        run: |
          curl -X POST "${{ secrets.SWRLY_WEBHOOK_URL }}" \
            -H "Content-Type: application/json" \
            -H "X-Webhook-Secret: ${{ secrets.SWRLY_WEBHOOK_SECRET }}" \
            -d '{
              "event": "deploy.completed",
              "environment": "production",
              "commit_sha": "${{ github.sha }}",
              "repository": "${{ github.repository }}",
              "actor": "${{ github.actor }}"
            }'
Enter fullscreen mode Exit fullscreen mode

The Swrly workflow receives that payload and can use it in agent prompts via template variables. An agent node downstream can reference {{trigger.commit_sha}} to know which commit was deployed.

Jenkins example. Same idea, different syntax:

post {
    success {
        httpRequest(
            url: env.SWRLY_WEBHOOK_URL,
            httpMode: 'POST',
            contentType: 'APPLICATION_JSON',
            customHeaders: [[name: 'X-Webhook-Secret', value: env.SWRLY_WEBHOOK_SECRET]],
            requestBody: """{"event":"deploy.completed","build_number":"${env.BUILD_NUMBER}"}"""
        )
    }
}
Enter fullscreen mode Exit fullscreen mode

GitLab CI example:

post-deploy-review:
  stage: post-deploy
  script:
    - |
      curl -X POST "$SWRLY_WEBHOOK_URL" \
        -H "Content-Type: application/json" \
        -H "X-Webhook-Secret: $SWRLY_WEBHOOK_SECRET" \
        -d "{\"event\":\"deploy.completed\",\"commit_sha\":\"$CI_COMMIT_SHA\"}"
  when: on_success
Enter fullscreen mode Exit fullscreen mode

Webhook triggers are fire-and-forget. Your CI/CD pipeline does not wait for the Swrly workflow to finish. It fires the webhook and moves on. The AI workflow runs asynchronously and posts results wherever you configure it -- Slack, GitHub comments, Linear issues.

API Triggers

API triggers are for when you need your CI/CD pipeline to wait for the AI workflow's result before proceeding. This is the deploy gate pattern.

The difference from webhooks: API triggers return a run ID immediately, and you can poll for the result or use a synchronous mode that waits for completion.

Deploy gate example in GitHub Actions:

- name: AI deploy gate check
  id: gate
  run: |
    RESPONSE=$(curl -s -X POST "https://api.swrly.com/api/v1/run" \
      -H "Authorization: Bearer ${{ secrets.SWRLY_API_KEY }}" \
      -H "Content-Type: application/json" \
      -d '{
        "swirlId": "your-swirl-id",
        "sync": true,
        "input": {
          "environment": "production",
          "commit_sha": "${{ github.sha }}",
          "changed_files": "${{ steps.changes.outputs.files }}"
        }
      }')
    DECISION=$(echo "$RESPONSE" | jq -r '.output.decision')
    echo "decision=$DECISION" >> "$GITHUB_OUTPUT"

- name: Block deploy on AI rejection
  if: steps.gate.outputs.decision == 'reject'
  run: |
    echo "AI deploy gate rejected this release. Check Swrly for details."
    exit 1
Enter fullscreen mode Exit fullscreen mode

This pattern is powerful for pre-deploy checks. The Swrly workflow can analyze the changes being deployed, check for risky patterns, verify that database migrations are backward-compatible, and return a go/no-go decision. Your pipeline respects that decision without needing to understand the AI logic.

Use sync: true for gates where you need the result inline. Use the async pattern with polling for longer workflows where you do not want to hold up a CI runner.

Event Triggers

Event triggers listen for events from connected integrations -- GitHub, Slack, Linear, PagerDuty -- and start workflows automatically. No webhook URL configuration needed. You connect your GitHub integration in Swrly and subscribe to events.

Post-deploy verification example. Instead of firing a webhook from your deploy script, you can configure a Swrly workflow to trigger on GitHub's deployment_status event. When GitHub reports a deployment as "success," the workflow starts automatically.

The workflow could:

  1. Pull the deployment details and commits included in the release
  2. Run a health check against the deployed environment via HTTP tools
  3. Compare error rates in Datadog before and after the deploy
  4. Post a deploy summary to Slack with a pass/fail assessment

Event triggers are cleaner than webhooks when your CI/CD system already emits events through a platform Swrly integrates with. You do not need to add curl commands to your pipeline -- the event flow already exists.

Cross-swirl triggers take this further. A Swrly workflow can trigger another Swrly workflow on completion. Your deploy verification workflow finishes, and if it detects issues, it triggers your incident triage workflow automatically. This chaining happens within Swrly without touching your CI/CD system at all.

Putting It Together

A typical CI/CD integration uses all three trigger types for different purposes:

Webhook triggers for fire-and-forget notifications: post-deploy changelogs, PR review requests, dependency audit kicks.

API triggers for synchronous gates: pre-deploy safety checks, change risk assessment, compliance verification.

Event triggers for reactive automation: deployment status monitoring, error spike detection, cross-workflow chaining.

The common pattern is: your CI/CD system stays in charge of building, testing, and deploying. Swrly handles the analysis, summarization, and decision-support that currently lives in human heads or does not happen at all.

Start with one webhook trigger on your deploy pipeline. Point it at a Swrly workflow that generates a deploy changelog and posts it to Slack. That takes 20 minutes to set up and gives your team immediate visibility. Expand from there.

What Not to Do

A few anti-patterns we have seen teams fall into:

Do not put AI in the critical deploy path on day one. Start with async, advisory workflows. Let the team build trust in the AI's judgment before giving it blocking power over deploys.

Do not try to replace your test suite. AI agents are good at reasoning about code changes and gathering context. They are bad at deterministic assertions. Your unit tests should still run. The AI adds a layer of semantic analysis on top.

Do not send your entire codebase as context. Send the diff, the changed files, and relevant metadata. Agents work better with focused context than with everything dumped into a prompt.

Do not skip the webhook secret. Swrly webhook triggers support HMAC verification. Use it. An unauthenticated webhook endpoint that triggers AI workflows is a security incident waiting to happen.

The goal is augmentation, not replacement. Your CI/CD pipeline is good at what it does. AI fills the gaps where pattern recognition and natural language reasoning add value. Keep the boundary clean, start small, and expand based on results.

Top comments (0)