1. What are common Jenkins issues and how do you troubleshoot them? Discuss build failures, agent connection issues, performance problems, and plugin conflicts.
Build failures troubleshooting starts with console output analyzing error messages. Common causes include missing dependencies (tools not installed on agent, wrong versions), environment issues (missing environment variables, wrong PATH), credential problems (expired or incorrect credentials), network issues (can't reach external services), resource constraints (out of memory, disk space), and flaky tests. Check if builds succeed locally, review recent changes (code, pipeline, Jenkins config), ensure agent has required tools with correct versions, verify credentials are valid and properly scoped. Agent connection issues manifest as agents showing offline or disconnected. Troubleshoot by checking network connectivity (can master reach agent on required ports?), verifying agent Java version matches requirements, reviewing agent logs (on agent machine in remoting directory), checking firewall rules allowing communication, verifying SSH credentials or JNLP connection settings, ensuring agent has sufficient resources (CPU, RAM, disk). For SSH agents, test SSH connection manually. For JNLP agents, check agent logs showing connection attempts. Performance problems include slow UI (Jenkins UI slow to respond), long build queue (jobs waiting for available agents), slow builds (builds taking longer than expected), high resource usage (CPU, memory, disk). Diagnose with performance monitoring: check JVM memory usage (heap, garbage collection), monitor agent utilization (executors busy vs idle), analyze disk I/O (slow disk affecting performance), review build durations identifying slowest stages. Solutions include JVM tuning (increase heap size), adding more agents for parallel execution, optimizing pipelines (caching, parallel stages), cleaning old builds and workspaces, upgrading hardware or moving to more powerful cloud instances. Plugin conflicts occur when plugins are incompatible with each other or with Jenkins core version. Symptoms include Jenkins failing to start, features not working, errors in logs. Troubleshoot by checking Jenkins log (JENKINS_HOME/logs/jenkins.log) for plugin errors, testing in safe mode (starts Jenkins without plugins) to isolate issue, updating plugins to compatible versions, rolling back recently installed plugins, checking plugin dependencies for conflicts. Use Plugin Installation Manager tool to analyze dependencies. Out of memory errors (OOM) indicate JVM heap exhaustion. Symptoms include builds failing with OutOfMemoryError, Jenkins becoming unresponsive, or crashes. Solutions: increase JVM heap size (-Xmx flag), analyze heap dumps (with tools like Eclipse MAT) identifying memory leaks, review plugins for memory leaks, implement build retention policies reducing memory usage, avoid storing large build artifacts in Jenkins. Disk space issues cause builds to fail with "No space left on device". Monitor disk usage with Disk Usage plugin, implement workspace cleanup (cleanWs() in pipelines), configure build retention policies discarding old builds, move artifacts to external storage (Artifactory, S3), clean Docker images if using Docker agents (docker system prune), add more disk space or mount external storage. Credential problems include expired credentials, wrong permissions, or credential not found errors. Verify credential exists with correct ID, check credential scope (Global vs System), test credential manually, ensure user/service account has required permissions, rotate credentials if expired, review audit logs for credential usage. Debugging techniques: enable debug logging for specific components (Manage Jenkins > System Log), use replay feature in Pipeline to test changes without committing, add echo statements for variable values and debug output, use timestamps() wrapper showing execution times, check Jenkins system log for backend errors, review SCM webhook delivery logs checking if webhooks reaching Jenkins. Common solutions: restart Jenkins (fixes many transient issues), rebuild agent (for persistent agent problems), clear browser cache (for UI issues), disable plugins one by one (to isolate plugin conflicts), restore from backup (for configuration corruption). Document troubleshooting steps and solutions in runbooks for team reference. Understanding troubleshooting techniques minimizes downtime and enables quick resolution of Jenkins issues.