File size: 16,159 Bytes
c2fe8c6
 
 
 
 
 
 
 
0365678
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2fe8c6
 
 
 
0365678
 
 
 
c2fe8c6
0365678
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2fe8c6
0365678
3ecb282
 
0365678
c2fe8c6
 
 
0365678
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2fe8c6
 
 
 
 
 
0365678
c2fe8c6
 
 
 
 
 
0365678
 
 
 
 
 
 
 
 
 
 
 
 
 
c2fe8c6
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Jenkins Error Explainer</title>
    <style>
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; padding: 40px 20px; }
        .container { max-width: 800px; margin: 0 auto; background: white; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; }
        .header { background: linear-gradient(135deg, #4a90d9 0%, #5c3cb8 100%); color: white; padding: 30px; text-align: center; }
        .header h1 { font-size: 28px; margin-bottom: 8px; }
        .header p { opacity: 0.9; font-size: 14px; }
        .content { padding: 30px; }
        textarea { width: 100%; height: 200px; padding: 15px; border: 2px solid #e0e0e0; border-radius: 12px; font-family: 'Monaco', 'Menlo', monospace; font-size: 13px; resize: vertical; transition: border-color 0.3s; }
        textarea:focus { outline: none; border-color: #667eea; }
        .btn { display: block; width: 100%; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; padding: 16px; font-size: 16px; font-weight: 600; border-radius: 12px; cursor: pointer; margin-top: 20px; transition: transform 0.2s, box-shadow 0.2s; }
        .btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4); }
        .btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
        #result { margin-top: 30px; display: none; }
        #result.show { display: block; animation: fadeIn 0.4s ease; }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
        .error-category { display: inline-block; background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%); color: white; padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 14px; margin-bottom: 15px; }
        .section { margin: 20px 0; }
        .section h3 { color: #333; font-size: 16px; margin-bottom: 10px; }
        .summary { background: #f8f9fa; padding: 15px; border-radius: 10px; line-height: 1.6; color: #555; }
        .causes { background: #fff3e0; padding: 15px; border-radius: 10px; }
        .causes ul { margin-left: 20px; color: #e65100; }
        .causes li { margin: 8px 0; }
        .references { background: #e8f5e9; padding: 15px; border-radius: 10px; }
        .references ul { margin-left: 20px; color: #2e7d32; }
        .references li { margin: 5px 0; }
        .footer { background: #f5f5f5; padding: 20px; text-align: center; color: #888; font-size: 12px; }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>🔧 Jenkins Error Explainer</h1>
            <p>AI-powered Jenkins pipeline error diagnosis</p>
        </div>
        
        <div class="content">
            <textarea id="logInput" placeholder="Paste your Jenkins error log here...

Example:
Started by user admin
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 10: expecting '}', found '' @ line 10, column 1
"></textarea>
            <button class="btn" onclick="explainError()" id="submitBtn">Analyze Error</button>
            
            <div id="result">
                <span class="error-category" id="category"></span>
                
                <div class="section">
                    <h3>📝 Summary</h3>
                    <div class="summary" id="summary"></div>
                </div>
                
                <div class="section">
                    <h3>🔍 Likely Causes</h3>
                    <div class="causes"><ul id="causes"></ul></div>
                </div>
                
                <div class="section">
                    <h3>📚 References</h3>
                    <div class="references"><ul id="references"></ul></div>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <p><strong>Architecture:</strong> RAG (Retrieval-Augmented Generation) using FAISS + LangChain</p>
            <p>Built with ❤️ for Jenkins Developers</p>
        </div>
    </div>

    <script>
        const ERROR_DATABASE = {
            groovy_syntax_error: {
                category: "Groovy Syntax Error",
                summary: "The pipeline failed due to a Groovy syntax error, most likely caused by an invalid or incomplete Jenkinsfile.",
                causes: [
                    "Missing or mismatched braces in the Jenkinsfile",
                    "Invalid declarative pipeline structure",
                    "Incorrect string quotes or special characters",
                    "Missing required keywords like 'pipeline', 'stages', or 'steps'"
                ],
                references: [
                    "Pipeline Syntax Reference (Jenkins.io)",
                    "Declarative Pipeline Documentation",
                    "Groovy Language Documentation"
                ]
            },
            missing_agent: {
                category: "Missing Agent",
                summary: "The pipeline attempted to execute a step that requires a node, but no agent was allocated.",
                causes: [
                    "Using 'agent none' without defining a stage-level agent",
                    "Executing node-dependent steps (like 'sh', 'node') without a workspace",
                    "Missing agent directive in declarative pipeline"
                ],
                references: [
                    "Agent Directive (Jenkins.io)",
                    "Pipeline Steps Documentation"
                ]
            },
            no_node_available: {
                category: "No Node Available",
                summary: "The pipeline could not be scheduled because no Jenkins node matched the requested label.",
                causes: [
                    "The specified node label does not exist",
                    "All matching nodes are offline or busy",
                    "No executors available on matching nodes",
                    "Node label typo or case mismatch"
                ],
                references: [
                    "Distributed Builds (Jenkins.io)",
                    "Node Label Plugin Documentation",
                    "Label Selector Plugin"
                ]
            },
            missing_plugin: {
                category: "Missing Plugin",
                summary: "The pipeline referenced a step that is not available, indicating a missing or uninstalled plugin.",
                causes: [
                    "Required plugin is not installed",
                    "Plugin is installed but not enabled",
                    "Incorrect step name in the Jenkinsfile",
                    "Plugin version mismatch"
                ],
                references: [
                    "Plugin Index",
                    "Pipeline Steps Reference",
                    "Managing Plugins Documentation"
                ]
            },
            missing_credentials: {
                category: "Missing Credentials",
                summary: "The pipeline referenced credentials that do not exist in Jenkins.",
                causes: [
                    "Credentials ID is incorrect or misspelled",
                    "Credentials were not configured in Jenkins",
                    "Credentials have expired or been deleted",
                    "User does not have permission to use the credentials"
                ],
                references: [
                    "Credentials Plugin Documentation",
                    "Using Credentials in Pipelines",
                    "Credential Binding Plugin"
                ]
            },
            file_not_found: {
                category: "File Not Found",
                summary: "The pipeline attempted to access a file that does not exist in the workspace.",
                causes: [
                    "File path is incorrect or has typos",
                    "File was not generated in previous build step",
                    "File was not checked out from version control",
                    "Working directory mismatch"
                ],
                references: [
                    "Pipeline Basic Steps",
                    "Workspace Plugin Documentation",
                    "File Operations Plugin"
                ]
            },
            git_authentication_error: {
                category: "Git Authentication Error",
                summary: "Jenkins failed to authenticate with the Git repository during checkout.",
                causes: [
                    "Invalid or missing Git credentials",
                    "SSH key not configured properly",
                    "Repository URL authentication method mismatch",
                    "Token has expired or been revoked"
                ],
                references: [
                    "Git Plugin Documentation",
                    "Credential Binding Plugin",
                    "SSH Credentials Plugin"
                ]
            },
            timeout_error: {
                category: "Timeout Error",
                summary: "The pipeline or a step took too long to complete and was terminated.",
                causes: [
                    "Step execution time exceeded timeout limit",
                    "Network latency or connection issues",
                    "External service not responding",
                    "Build queue is too long causing delays"
                ],
                references: [
                    "Timeout Step Documentation",
                    "Pipeline Timeout Configuration",
                    "Jenkins Queue Management"
                ]
            },
            out_of_memory: {
                category: "Out of Memory",
                summary: "The build failed due to insufficient memory allocation.",
                causes: [
                    "JVM heap size too small for the build",
                    "Memory leak in the application",
                    "Too many parallel builds consuming memory",
                    "Large file processing exceeding limits"
                ],
                references: [
                    "JVM Memory Tuning",
                    "Pipeline Resource Management",
                    "Kubernetes Memory Limits"
                ]
            },
            permission_denied: {
                category: "Permission Denied",
                summary: "The pipeline attempted an operation without sufficient permissions.",
                causes: [
                    "Insufficient file system permissions",
                    "Missing role-based access control (RBAC) permissions",
                    "Pipeline lacks required approval or authorization",
                    "Security realm authentication failure"
                ],
                references: [
                    "Matrix Authorization Strategy",
                    "Role-Based Access Control Plugin",
                    "Pipeline Security Documentation"
                ]
            },
            docker_error: {
                category: "Docker Error",
                summary: "The pipeline failed while building or running Docker containers.",
                causes: [
                    "Docker daemon not running or not accessible",
                    "Invalid Docker image name or tag",
                    "Dockerfile syntax errors",
                    "Insufficient permissions to pull images"
                ],
                references: [
                    "Docker Pipeline Plugin",
                    "Dockerfile Reference",
                    "Kaniko vs Docker Build"
                ]
            },
            unknown: {
                category: "Unknown Error",
                summary: "The error could not be confidently identified. Please check the error message for more details.",
                causes: [
                    "Review the full error log for specific details",
                    "Check Jenkins system logs for more information",
                    "Search Jenkins community forums for the error",
                    "Contact Jenkins administrators for help"
                ],
                references: [
                    "Jenkins Pipeline Troubleshooting Guide",
                    "Jenkins Users Mailing List",
                    "Jenkins Community Forum"
                ]
            }
        };

        function detectErrorCategory(log) {
            const lower = log.toLowerCase();
            
            if (lower.includes('groovy') && (lower.includes('syntax') || lower.includes('expecting') || lower.includes('failed'))) {
                return 'groovy_syntax_error';
            }
            if (lower.includes('agent') && (lower.includes('none') || lower.includes('null'))) {
                return 'missing_agent';
            }
            if (lower.includes('no node') || lower.includes('no such agent') || lower.includes('label')) {
                return 'no_node_available';
            }
            if (lower.includes('no such dsl') || lower.includes('undefined method') || lower.includes('not a valid step')) {
                return 'missing_plugin';
            }
            if (lower.includes('credentials') && (lower.includes('not found') || lower.includes('null') || lower.includes('missing'))) {
                return 'missing_credentials';
            }
            if (lower.includes('file not found') || lower.includes('no such file') || lower.includes('does not exist')) {
                return 'file_not_found';
            }
            if ((lower.includes('git') || lower.includes('checkout')) && (lower.includes('authentication') || lower.includes('failed') || lower.includes('permission'))) {
                return 'git_authentication_error';
            }
            if (lower.includes('timeout') || lower.includes('timed out') || lower.includes('deadline exceeded')) {
                return 'timeout_error';
            }
            if (lower.includes('outofmemory') || lower.includes('out of memory') || lower.includes('heap space') || lower.includes('oom')) {
                return 'out_of_memory';
            }
            if (lower.includes('permission denied') || lower.includes('access denied') || lower.includes('unauthorized')) {
                return 'permission_denied';
            }
            if (lower.includes('docker') && (lower.includes('error') || lower.includes('failed') || lower.includes('not found'))) {
                return 'docker_error';
            }
            return 'unknown';
        }

        function explainError() {
            const logText = document.getElementById('logInput').value;
            const resultDiv = document.getElementById('result');
            const btn = document.getElementById('submitBtn');
            
            if (!logText.trim()) {
                alert('Please provide a Jenkins error log.');
                return;
            }
            
            btn.disabled = true;
            btn.textContent = 'Analyzing...';
            
            setTimeout(() => {
                const category = detectErrorCategory(logText);
                const info = ERROR_DATABASE[category];
                
                document.getElementById('category').textContent = info.category;
                document.getElementById('summary').textContent = info.summary;
                document.getElementById('causes').innerHTML = info.causes.map(c => `<li>${c}</li>`).join('');
                document.getElementById('references').innerHTML = info.references.map(r => `<li>${r}</li>`).join('');
                
                resultDiv.classList.add('show');
                
                btn.disabled = false;
                btn.textContent = 'Analyze Error';
            }, 500);
        }
    </script>
</body>
</html>