1. GoCD Agent Not Connecting to the Server

Understanding the Issue

One of the most common issues in GoCD is agents failing to connect to the GoCD server, resulting in pipelines not executing as expected.

Root Causes

  • Firewall or network restrictions blocking agent-server communication.
  • Incorrect agent registration key or missing agent auto-registration properties.
  • Mismatch between the GoCD server version and agent version.

Fix

Ensure the agent can reach the server on the required port (default is 8153 for HTTP and 8154 for HTTPS):

telnet gocd-server-ip 8153

Verify the agent auto-registration file includes the correct values:

echo "agent.auto.register.key=your-registration-key" > /var/lib/go-agent/config/autoregister.properties

Ensure that both the server and agent versions are compatible:

gocd-server --version
gocd-agent --version

2. GoCD Pipeline Stuck in 'Waiting for an Agent'

Understanding the Issue

Even when agents are online, pipelines may remain in a 'Waiting for an Agent' state, preventing jobs from executing.

Root Causes

  • Insufficient resources or incorrect agent assignment.
  • Pipeline jobs requiring agents with specific capabilities not available.
  • Agent has become unresponsive or disconnected.

Fix

Check if agents are available and properly assigned:

go-agent status

Ensure that the correct agent resources are specified in the pipeline configuration:

resources: ["java", "docker"]

Restart the agent and server to refresh the connection:

systemctl restart go-agent
gocd-server restart

3. GoCD Server Running Out of Disk Space

Understanding the Issue

GoCD servers can accumulate a large amount of build artifacts and logs over time, leading to performance degradation.

Root Causes

  • Old pipeline artifacts and logs are not being cleaned up.
  • Database growth due to unoptimized configurations.

Fix

Clean up old artifacts using the cleanup command:

gocd-server cleanup

Adjust GoCD artifact retention settings:

# config.xml
<artifact_purge_settings defaultArtifactPurgeSettings="true" keepFileBasedArtifacts="10" keepBuildArtifacts="5" />

Monitor disk usage and set up automated cleanup scripts:

du -sh /var/lib/go-server/artifacts

4. Pipeline Execution Is Slow

Understanding the Issue

Pipelines in GoCD can experience slow execution times due to inefficient job distribution or excessive resource consumption.

Root Causes

  • Agents running on underpowered hardware.
  • Too many concurrent jobs competing for resources.
  • Build steps that are not optimized.

Fix

Analyze pipeline execution times and optimize job execution:

go-server job-duration --pipeline my_pipeline

Distribute workload by increasing the number of agents:

kubectl scale deployment go-agent --replicas=5

Use caching mechanisms for dependencies to reduce redundant downloads:

cache:
  paths:
    - ~/.m2/repository
    - ~/.npm

5. SSL/TLS Errors in GoCD

Understanding the Issue

Securely configuring GoCD over HTTPS can lead to certificate errors that prevent communication between agents and the server.

Root Causes

  • Self-signed certificates not trusted by GoCD agents.
  • Incorrect SSL configuration in GoCD.

Fix

Generate and install a valid SSL certificate:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

Configure GoCD to use the SSL certificate:

# server.sh
export GO_SERVER_SYSTEM_PROPERTIES="-Dserver.ssl.key-store=keystore.jks"

Restart the server to apply changes:

systemctl restart go-server

Conclusion

GoCD provides a highly customizable CI/CD pipeline for enterprises, but troubleshooting common issues such as agent connectivity, pipeline execution delays, storage constraints, and SSL misconfigurations is essential for maintaining a stable deployment. By applying best practices like resource management, security hardening, and regular cleanup, teams can ensure efficient CI/CD workflows.

FAQs

1. How do I fix an unresponsive GoCD agent?

Check network connectivity, restart the agent, and verify the correct auto-registration properties.

2. Why is my GoCD pipeline stuck in 'Waiting for an Agent'?

Ensure agents are assigned the correct resources and restart the agent if it appears offline.

3. How do I reduce disk usage on the GoCD server?

Configure artifact retention policies, clean up old logs, and monitor disk space usage regularly.

4. How can I speed up GoCD pipeline execution?

Increase the number of agents, optimize job dependencies, and implement caching mechanisms for build steps.

5. How do I secure GoCD with SSL?

Generate a valid SSL certificate, configure GoCD's HTTPS settings, and ensure agents trust the certificate.