Skip to main content
  1. Posts/

Jenkins Plugin Center Didn't Have an AI Plugin Yet? I Wrote One! 🤖

·751 words·2 mins· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

As the title says, I recently launched my first Jenkins plugin! 🎉

The main function of this plugin is to eliminate the need to copy error messages from Jenkins builds into AI tools like ChatGPT for analysis. Instead, it provides a button directly in the Jenkins build log. Clicking this button automatically sends the error information to OpenAI for analysis. You can also add an explainError() step in your pipeline to get error explanations, helping developers locate and solve problems faster.

This is my first plugin project in the Jenkins community. Previously, I hadn’t attempted this because I believed many functionalities could be implemented via pipeline scripts, making a separate plugin unnecessary.

However, with the increasing popularity of AI, I discovered that the Jenkins Plugin Center surprisingly lacked a similar plugin. So, I decided to implement this functionality myself. With the help of AI, and utilizing my evenings for development and testing, along with thorough code reviews from the Jenkins Hoster, I finally submitted it to the Jenkins Plugin Center last weekend, and it’s officially online.

Plugin Introduction
#

Explain Error Plugin is a Jenkins plugin based on OpenAI. It automatically parses build failure log information and generates readable error explanations, suitable for common Jenkins job types such as Pipeline and Freestyle.

  • 🔍 One-click analysis of errors in console output
  • ⚙️ Usable in Pipelines with a simple explainError() step
  • 💡 AI-powered intelligent explanations based on the OpenAI GPT model
  • 🌐 Provides two Web UI options to display AI-generated analysis results
  • 🎯 Customizable: Supports setting the model, API address, log filters, and more

Plugin Highlights
#

FeatureDescription
✅ One-click console analysisAdds an “Explain Error” button to the top of the console page
✅ Pipeline supportProvides the explainError() step, automatically triggered on failure
✅ Model configuration supportCustomize to use GPT-3.5 or other models
✅ Jenkins CasC supportSupports Configuration as Code
✅ Log filteringSupports regular expression filtering of logs to focus on error content

Prerequisites
#

  • Jenkins version ≥ 2.479.3
  • Java version ≥ 17
  • An OpenAI API Key (available at OpenAI website)

Quick Installation
#

You can install it through the Jenkins Plugin Manager:

Manage Jenkins → Manage Plugins → Available → Search for “Explain Error Plugin”

Plugin Configuration
#

After installation, find Explain Error Plugin Configuration under Manage Jenkins → Configure System to configure your OpenAI API key and model:

SettingDescriptionDefault Value
Enable ExplanationEnable AI analysis functionality✅ Enabled
API KeyYour OpenAI KeyRequired
API URLOpenAI API addresshttps://api.openai.com/v1/chat/completions
AI ModelModel to usegpt-3.5-turbo

Explain Error Plugin Configuration

You can also manage these settings through Jenkins Configuration as Code, for example:

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

How to Use
#

Using in Pipelines
#

It’s recommended to call explainError() within the post { failure { ... } } statement to automatically analyze errors on build failure:

post {
  failure {
    explainError()
  }
}

You can also set the log length and matching keywords:

explainError(
  maxLines: 500,
  logPattern: '(?i)(error|failed|exception)'
)

Using in the Console
#

Suitable for any type of Jenkins job:

  1. Open the console output page of the failed build
  2. Click the “Explain Error” button at the top
  3. The AI analysis results will be displayed below the button

Preview
#

After a build failure, a sidebar entry will appear on the job page. Clicking it will display the AI analysis results:

Explain Error Plugin

Or directly click “Explain Error” on the console page to view the analysis:

Explain Error Plugin Console

Future Plans
#

  • Error caching: Avoid repeated calls to OpenAI when analyzing the same error multiple times to save calls. (Already implemented, awaiting merge)
  • Multi-model support: Support other AI platforms, such as Google Gemini, Claude, DeepSeek, etc.

These features are still under development, conception, and refinement. Your feedback and suggestions are highly welcome.

In Closing
#

The plugin is completely open-source. Feel free to try it out and contribute code!

If you encounter any problems during use or have suggestions, please submit an issue or pull request on GitHub:

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

If you find this plugin helpful, please share this article; you can also give it a Star ⭐ on GitHub to show your support!

This is the most direct support for open-source projects 🙌


Please indicate the author and source when reprinting this article, and do not use it for any commercial purposes. Welcome to follow the WeChat official account “DevOps攻城狮”

Related

Jenkins Multibranch Pipeline
·405 words·2 mins
Discusses the use of Jenkins Multibranch Pipeline to manage multiple branches in a project, enabling parallel builds for pull requests and efficient code review processes.
Jenkins Linux agent configuration
·298 words·2 mins
Provides a step-by-step guide on how to configure a Jenkins Linux agent, including setting up the Java runtime, creating the node, and troubleshooting common issues.
Jenkins Windows agent configuration
·544 words·3 mins
Provides a step-by-step guide on how to configure a Jenkins Windows agent, including setting up the Java runtime, creating the node, and troubleshooting common issues.
How to Fix Shields.io Badges Not Displaying in Jenkins
·218 words·2 mins
How to temporarily fix it via the Script Console, and how to make it permanent by modifying Jenkins startup parameters. This method is suitable for internal Jenkins environments and has been tested on modern Jenkins installations.
How to Change abortPrevious Value in Jenkins?
·418 words·2 mins
In Jenkins, the disableConcurrentBuilds option is used to manage concurrent builds. This article explains how to conditionally set the abortPrevious value based on the branch being built, allowing for more flexible build management.
What Optimizations I Made During the Jenkins Upgrade
·481 words·3 mins
This article discusses the optimizations made during the Jenkins upgrade, including using Docker Compose for deployment, refactoring the Jenkins Shared Library, introducing Windows Docker Containers, and more to enhance the efficiency and security of the CI/CD process.