ScreenshotNeo

BlogHow-to

How to Build an Automated Testing Pipeline With GoCD

Build a GoCD pipeline that runs tests on code changes, publishes test reports and artifacts, and passes outputs safely between stages.

By the ScreenshotNeo team4 October 20268 min read

To build an automated testing pipeline with GoCD, connect a source repository as a pipeline material, configure one or more stages with jobs that run your test commands on GoCD agents, and publish the resulting test reports and build outputs as artifacts. GoCD detects material changes and schedules work; agents execute the jobs. The test runner and its dependencies must be installed or provisioned on eligible agents.

A practical first pipeline has a fast build and unit-test stage, followed by slower integration or acceptance checks when the project needs them. Stages run in order, jobs in a stage can run independently, and tasks in a job run in order. A failed task fails its job; a failed stage stops later stages by default. GoCD pipeline concepts

1. Choose what triggers the pipeline

For checks that should run when code changes, use the source repository as a material. GoCD checks materials for changes and can trigger the pipeline when a change is detected. Pipeline dependencies, package repositories, and material plugins are other possible inputs, depending on the workflow.

You can set up a pipeline through pipelines as code, the GoCD API, the web UI, or by cloning an existing pipeline. Choose the method that fits how your team reviews and manages configuration. GoCD pipeline setup guide

2. Design stages, jobs, and tasks

Use a stage boundary where a later kind of work should wait for an earlier gate to pass. For example, a build and unit-test stage can run before integration checks. This is a design pattern, not a required test taxonomy. Keep independent work in separate jobs within a stage when it can safely run in parallel.

  • Pipeline: the workflow and its materials.
  • Stage: an ordered gate in the workflow.
  • Job: a unit of work that an agent executes; jobs in a stage can be independent.
  • Task: a command or operation within a job; tasks run in order.

Use job resources to direct work to capable agents. An agent must have all resources specified by a job to run it. Parallel jobs need enough eligible agent capacity; otherwise some jobs wait. GoCD configuration reference

3. Prepare agents to run your test command

GoCD agents run the task commands, but GoCD does not install your project’s test framework for you. Install or provision the required language runtime, test runner, build tool, and service dependencies on agents that can receive the job. The GoCD setup guide notes that tools such as Ant, NAnt, and Rake are not bundled when selected as task types; the same principle applies to dependencies used by a custom command. Pipeline setup requirements

Make agent setup repeatable. Keep tool versions and service prerequisites consistent across eligible agents, and ensure that a job’s declared resources match the agents intended to run it. If test results differ between agents, first compare their runtime versions, environment variables, working directories, and external service configuration.

4. Configure test execution and publish reports

Add a task that invokes the project’s existing test command. The command and report path depend on the language and runner; GoCD orchestrates the command rather than replacing it. Configure the test report directory as a test artifact in the job, using the report format and path produced by your runner.

GoCD documents support for JUnit and NUnit reports. When those reports are published, GoCD lists tests in a Tests tab and copies the report artifacts into the server’s artifact repository. Confirm that the test command writes report files under the configured path; an empty or mismatched path cannot produce the expected test view. Managing artifacts and test reports

Coverage reports and diagnostic files can be published as ordinary artifacts. If an HTML report should be viewable in GoCD, configure a tab for it. Keep related resources alongside the HTML and use relative paths so the report can load its associated files.

5. Publish build outputs and pass them downstream

Test reports and build outputs have different purposes. Test artifacts let GoCD display test results; build artifacts carry files that later jobs or pipelines need. Declare output artifacts in the producer job, then configure downstream work to fetch the required artifact.

GoCD’s fetch-artifact task can retrieve artifacts from earlier stages in the same pipeline or from ancestor pipelines reached through pipeline dependency materials, subject to the documented upstream-stage constraints. Make the producer and consumer paths explicit, and ensure the downstream job depends on the producer’s pipeline or stage as intended. Artifact and fetch-artifact configuration

6. Keep pipeline configuration reviewable

Pipelines as code can put configuration changes under version control and review. GoCD documents JSON and YAML config repository plugins; the server periodically checks repository definitions and merges them with the main configuration.

Treat config repositories as privileged. Pipeline definitions can execute tasks, so restrict which pipeline groups and dependencies each repository may affect. GoCD’s documentation warns that this capability is akin to remote code execution in a privileged or trusted environment. Configure explicit rules before granting a repository permission to define pipelines. GoCD pipelines as code and security

7. Validate the pipeline with a real run

  1. Make a small change to the configured material or use the pipeline’s manual trigger.
  2. Confirm GoCD schedules the pipeline and assigns each job to an eligible agent.
  3. Check the agent output for the expected working directory, command, and test exit status.
  4. Open the job’s artifacts and verify the report files exist at the configured paths.
  5. Open the Tests tab to confirm GoCD lists the report’s tests.
  6. Check that downstream jobs fetch the intended artifact and receive the expected files.
  7. Cause a controlled test failure in a safe branch and confirm the failed stage prevents later stages from starting by default.

Do not infer that reports or artifact handoffs work just because the job is green. Verify the generated files and the downstream consumer in an actual run.

How should you choose stage boundaries and parallel jobs?

Decision Useful approach Tradeoff to check
Fast checks versus longer suites Run quick checks early; place slower checks in later gated stages when they address distinct risks. Later feedback arrives after earlier stages finish. GoCD documentation does not quantify a speed improvement.
Parallel jobs Split independent platforms or suites into jobs in the same stage. Parallel work needs eligible agents and consumes more concurrent capacity.
Agent selection Assign job resources that describe required capabilities. An agent missing any required resource cannot take that job.
Artifact handoff Publish only outputs needed for reports, debugging, or later work; fetch them where consumed. Incorrect paths or dependency relationships break downstream work.
Repeatability Provision consistent toolchains and external dependencies on eligible agents. Teams must maintain that environment; GoCD does not install project dependencies automatically.

Troubleshooting common GoCD testing pipeline problems

Symptom Likely cause What to check or fix
Pipeline does not start after a code change The repository is not configured as a material, the change was not detected, or the pipeline trigger configuration does not match the intended workflow. Check the pipeline’s material and its status in GoCD. Confirm the repository URL, branch or revision settings, and trigger behavior.
Job stays scheduled or waits for an agent No available agent has every resource required by the job, or eligible agents are unavailable. Compare the job’s resources with agent resources and check agent availability. Add capacity or correct resource labels.
Test task fails with “command not found” or a missing runtime error The toolchain is absent from the assigned agent or not on its execution PATH. Install or provision the runtime and test tools on eligible agents; verify the command under the agent’s execution environment.
Tests pass but the Tests tab is empty The runner did not generate a supported report, or the configured report path or pattern does not match the generated files. Inspect the job workspace and artifact listing. Configure the actual JUnit or NUnit report output path and rerun.
GoCD cannot render an HTML report correctly Related CSS, JavaScript, or images are missing from the published files, or the report refers to the wrong paths. Publish associated files and use relative resource paths; configure the tab to point to the report entry file.
Downstream job cannot find a build output The producer did not declare the file as an artifact, the consumer fetch path is wrong, or the required pipeline dependency is absent. Check the producer artifact declaration, dependency material, fetch-artifact configuration, and destination path.
Pipeline-as-code changes affect an unexpected group Config repository permissions are broader than intended. Review explicit rules for pipeline groups and dependencies the repository is allowed to affect.
Results differ across agents Agent environments, tool versions, variables, or external dependencies differ. Compare the environments and make provisioning consistent for all agents eligible for the job.

Performance, reliability, and cost considerations

Pipeline feedback time depends on test duration, stage ordering, agent availability, and whether independent jobs can run concurrently. GoCD’s documented mechanics allow independent jobs in a stage to run separately, but parallelism requires suitable agent capacity. There is no GoCD-specific speed or reliability figure in the documentation used for this guide.

For reliable runs, keep agent toolchains consistent, make test commands return meaningful exit codes, and confirm reports and artifacts are actually generated. Separate fast checks from longer suites when that helps developers get earlier feedback, and retain only artifacts that support inspection or downstream work. The operational cost is mainly the infrastructure and capacity needed for GoCD server and agents, plus the time spent maintaining toolchains and test dependencies; the cited GoCD documentation does not provide a universal cost estimate.

Or skip the browser setup

If a test pipeline needs website screenshots for visual checks or report attachments, you can automate a browser yourself, or use ScreenshotNeo, a website screenshot API and MCP server for developers. Its one-call API returns a PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up free for 1,000 screenshots a month, no card required.

Frequently asked questions

Does GoCD run my test framework?

No. The agent runs the command you configure. Install or provision the test runner and its dependencies on eligible agents.

Which test report formats does GoCD document?

The artifact guide documents JUnit and NUnit reports. Check the documentation for the GoCD release you operate before relying on a particular configuration detail.

Can multiple jobs run at once?

Independent jobs within a stage can run in parallel when suitable agents are available. Tasks inside one job run in order.

Can a later pipeline use an earlier pipeline’s output?

Yes. Declare the upstream pipeline as a dependency material and configure a fetch-artifact task, subject to GoCD’s upstream-stage rules.

Where can I learn the broader deployment-pipeline model?

Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation by Jez Humble and David Farley is optional further reading on build, test, and deployment automation. It is a general delivery book, not a GoCD-specific manual. Pearson catalog listing