Building an Automated Test Pipeline with GoCD Cloud
By Manish Saini, Community Contributor - September 13, 2022
Automated testing for CI/CD enables your teams to build, test and deploy frequently. This helps you improve your product’s reliability by reducing bugs, increasing quality, and allowing the developers confidence that their latest version has robust functionality.
The business pressure to deliver faster shouldn’t diminish the quality of what is being produced. After all, your users expect stable and working software, even when they’re clamoring for the next shiny thing. In this article, we will learn about GoCD – an open-source Continuous Integration and Continuous Delivery system, and how to use that for our test automation.
What is GoCD?
GoCD is a free CI/CD tool for DevOps projects. It helps software development teams to automate the testing and release process. It was designed for continuous delivery, and developers can configure pipelines as code. Not only is it a robust and scalable but also an extensible open-source continuous delivery tool.
It supports several version control tools, including Git, Mercurial, Subversion, Perforce, and TFVC. Other version control software can be supported by installing additional plugins. It works in a master-slave architecture, i.e. there will be a single machine that controls the other agents.
The GoCD Server acts as a master in the above diagram and delegates the jobs to the agents.
Main Features of GoCD
GoCD has an excellent feature list. Some of them are:
- Free and open source
- Parallel and sequential execution
- Easily configure dependencies
- Configure pipelines as code
- Visualize workflows
- Compare builds
- Eliminate bottlenecks
- Keep configuration tidy
- Supports auditable deployment
- Supports plugins
- Deploy any version, any time
Also Read: GoCD vs Jenkins: Detailed Comparison
Set up GoCD Pipeline
A group of stages forms a pipeline. The pipeline can be dependent on the previous job’s completion status. Before setting up the GoCD pipeline, we should have these two essential components, installed in our system.
- GoCD server: The one which provides work for the agents
- GoCD agents: The ones that perform the assigned work like running scripts, building, deployment, etc.
Since installation instructions vary per operating system, the installation instruction pages linked below will ask you to choose your operating system and then provide you instructions for that operating system.
Steps to Install
After the installation, run the GoCD server locally on the default port http://localhost:8153/. Click on Admin -> Pipelines, which will take you to the pipelines administration page.
Click on the “Create a new pipeline within this group” button to the “Add pipeline” page.
Part 1: Material
1. Choose the material type. The material can be your Source Control Management (SCM or version control) repository, pipeline, or package repository (e.g. Git). Currently, GoCD supports the following:
- Team Foundation Server.
- Package repository
- Material Plugins
2. In the Repository URL, enter the repository URL.
3. Click Test Connection. If GoCD establishes a connection successfully, the Connection OK message appears.
Part 2: Pipeline Name
- Provide the pipeline a name, without spaces, for example, sample-pipeline.
- Select a pipeline group. Also, fill in the parameter if using a template.
Part 3: Stage Details
- Enter a name for the stage, for example, testing-stage.
Part 4: Job and Task
1- Enter a name for the job, for example, single-job.
2- In the console, add the commands required to run your project code. For example, if tests are based on Python, you need to add the commands required to set up and run a Python project.
3- Click Save + Run This Pipeline to save and run your pipeline.
The pipeline runs and the test result is displayed on your GoCD Dashboard page.
BrowserStack Integration with GoCD
Before you can start integration, ensure that you have access to the BrowserStack account credentials, namely Access Key and Username. For the Integration, you have to follow all the above steps same as before. But in the last step “Job and Task”, under “Advanced Settings”, in the Secure Variables section, You have to add your BrowserStack Username and Access key as the environment variables.
With existing test cases, integrating BrowserStack involves editing your test cases to add BrowserStack capabilities, credentials, and, remote URLs.
A well-orchestrated pipeline makes the job easier for the team and ensures reliable deployment and delivery. In this GoCD pipeline tutorial, we had a detailed look at configuring the GoCD pipeline. Combined with BrowserStack Automate, you have the flexibility to scale as your testing grows, without having to worry about updating versions, adding devices, managing capacity, and most importantly, maintaining stability.