DEV Community

Xianpeng Shen
Xianpeng Shen

Posted on

New Jenkins Plugin: Let AI Explain Your Build Failures

Recently, I released my first-ever Jenkins plugin – and it's now officially available in the Jenkins Center! 🎉

This plugin makes it possible to analyze build errors with AI directly inside Jenkins, so you no longer need to copy and paste logs into ChatGPT or other tools. Instead, you'll see an "Explain Error" button right in the console output, and you can also use the explainError() step in your pipeline to trigger AI analysis automatically when a build fails.

This is my first contribution to the Jenkins plugin ecosystem. I used to think most things could be handled by pipeline scripts, and there wasn’t much need for custom plugins. But as AI becomes increasingly mainstream, I noticed something surprising: Jenkins still didn’t have a plugin for AI-based error explanation. So, I decided to build one myself.

With the help of AI and some late-night coding sessions, along with several rounds of thorough code review from the Jenkins Hosting team, the plugin finally went live last weekend. 🚀

Introducing the Plugin

Explain Error Plugin is an OpenAI-powered Jenkins plugin that can automatically analyze logs from failed builds and generate easy-to-understand explanations. It works with both Pipeline and Freestyle job types.

GitHub repo: https://github.com/jenkinsci/explain-error-plugin

Demo

👉 Watch the hands-on demo on YouTube — setup, run, and see how AI explains your Jenkins job failures.

Key Features

Feature Description
✅ One-click console error explanation Adds an “Explain Error” button to the build log view
✅ Pipeline support Use explainError() in your pipeline scripts
✅ Custom model support Choose GPT-3.5 or other models
✅ Jenkins CasC compatible Supports Configuration as Code
✅ Log filtering Use regex patterns to focus on error content

Requirements

  • Jenkins version ≥ 2.479.3
  • Java version ≥ 17
  • An OpenAI API key (you can get one at OpenAI)

How to Install

Go to Manage Jenkins → Manage Plugins → Available, then search for:

“Explain Error Plugin”

And install it like any other Jenkins plugin.

Configuration

Once installed, head to Manage Jenkins → Configure System and scroll to Explain Error Plugin Configuration to enter your OpenAI settings.

Setting Description Default
Enable Explanation Enable/disable AI explanation ✅ Enabled
API Key Your OpenAI API key Required
API URL OpenAI endpoint https://api.openai.com/v1/chat/completions
AI Model Model to use gpt-3.5-turbo

Explain Error Plugin Configuration

Prefer managing Jenkins with Configuration as Code? You can configure it like this:

unclassified:
  explainError:
    enableExplanation: true
    apiKey: "${AI_API_KEY}"
    apiUrl: "https://api.openai.com/v1/chat/completions"
    model: "gpt-3.5-turbo"
Enter fullscreen mode Exit fullscreen mode

How to Use It

In Your Pipeline

Best used in a post { failure { ... } } block so it automatically analyzes failures:

post {
  failure {
    explainError()
  }
}
Enter fullscreen mode Exit fullscreen mode

You can also customize how logs are filtered:

explainError(
  maxLines: 500,
  logPattern: '(?i)(error|failed|exception)'
)
Enter fullscreen mode Exit fullscreen mode

In Console Output

This works for any job type:

  1. Go to the console output of a failed build
  2. Click the “Explain Error” button at the top
  3. The AI-generated explanation will appear below the button

Demo Preview

When a build fails, you’ll see a sidebar entry on the build page where the AI explanation will be shown:

Explain Error Plugin

Or you can view the explanation directly on the console page after clicking the “Explain Error” button:

Explain Error Plugin Console

What’s Next

  • Error caching: Avoid redundant API calls for the same errors (already implemented, pending merge)
  • Multi-model support: Plan to support other AI services like Gemini, Claude, DeepSeek, etc.

More features are under development or in the idea phase — and your feedback is always welcome!

Final Thoughts

The plugin is 100% open source — contributions and suggestions are very welcome!

If you try the plugin and find it useful, feel free to share this article, or give the project a ⭐ on GitHub:

GitHub: https://github.com/jenkinsci/explain-error-plugin

That’s the best way to support open-source work like this. 🙌

Top comments (0)