I started a hobby project during my free time to improve some daily problems in a software engineer’s life using Gen AI. The first one on my list was a simple AI agent that optimizes Gitlab DevOps pipelines.

An AI agent to manage a DevOps pipeline in GitLab is a powerful tool that combines automation, decision-making, and continuous delivery. The agent will take care of analyzing the pipeline and provide the required actions in case of any failure.

The agent can be developed in two phases.

  1. An Agent that monitors the pipeline and provides the corrective measures in case of any failures
  2. An Agent that performs everything in Phase 1 + performs the corrective measures to fix the failed pipeline (Advanced

The following are the core features that I outlined for my AI agent.

Pipeline Monitoring (phase 1)

  • Detect failed pipelines.
  • Auto-diagnose common failure reasons (e.g. dependency issues, syntax errors).
  • Suggest the fixes for known patterns.

Healing or Applying the fixes (phase 2)

  • Auto apply the fixes and heal the failed pipeline

Resource Optimization (phase 2)

  • Recommend optimal runner configurations (e.g., instance types, concurrency).
  • Predict runtime and suggest parallelization opportunities.

Smart Triggering (phase 2)

  • Determine which parts of a monorepo need to be tested/deployed based on code diff.
  • Avoid unnecessary pipeline runs.

Security & Compliance

  • Monitor for secrets in commits.
  • Enforce policy checks on merge requests (e.g. license compliance, code quality).

ChatOps Integration (phase 2)

  • Interface with Slack/MS Teams to answer questions or take commands:
    • “Why did the last pipeline fail?”
    • “Deploy staging with feature-X branch”

The following are the technical steps involved in building the first version of the AI DevOps Agent. I will be using the Python programming language for developing the components. You can use any programming language of your choice to build the same.

  • Set up a FastAPI app to receive pipeline webhooks.
  • Parse the event and check for failure.
  • Fetch job logs using GitLab API.
  • Run analysis on logs (AI based Analysis).
  • Post a comment on the MR with diagnosis.

I will walk you through the development of each of the above components to build the first version of the AI agentic DevOps engine in my next blog post. The links to the post will be attached below once I publish the blogs.