Building a CI/CD Pipeline from Scratch with DeployHQ: A Step-by-Step Guide

Devops & Infrastructure, Tips & Tricks, and Tutorials

Building a CI/CD Pipeline from Scratch with DeployHQ: A Step-by-Step Guide

A CI/CD (Continuous Integration + Continuous Deployment) pipeline is a widely embraced approach to development because it supports faster and less error-prone releases.

Continuous integration (CI) allows developers to automatically integrate code changes into a shared repository and run automated tests each time the code is updated. Continuous deployment (CD) lets them directly deploy the code that passes all tests to production or staging environments.

If testing is (or should be!) the bread and butter of every software dev, building ad-hoc testing suites can be time-consuming and keep developers from focusing on creating. Integrating tests and deployment within an active pipeline can make operations run smoother and support a healthy development experience: fewer errors, faster releases, more peace of mind.

DeployHQ is a cloud-based deployment tool that lets you build CI/CD pipelines quickly and effortlessly. Its easy integration with popular platforms like GitHub, GitLab, and Bitbucket, multiple possible deployment targets, and templates to standardize setup allow you to build a pipeline that integrates, scales easily, and runs with a click.

In this article, you will learn to set up a pipeline from code integration to specific deployments.

Understanding CI/CD pipeline components

At large, CI/CD pipeline components include the following:

  • Source code management (SCM): Where your code resides. Popular tools include GitHub, CodeBase, GitLab, and Bitbucket, all of which are supported by DeployHQ.

SCM DeployHQ

  • Automated builds: Tools like Jenkins, GitHub Actions, or DeployHQ deployment pipelines support automated project building.
  • Automated testing: Unit tests, integration tests, end-to-end tests—we should all be testing our application against all odds. So why not automate this part? This way, you can guarantee quality while keeping testing hands-off.
  • Automated deployments: With DeployHQ, pushing code to your servers of choice can be set up as an automatic action. Pick your deployment targets, and you are ready to go.

It’s important to stress the importance of each of these CD/CD components in maintaining a reliable pipeline. Workflows can be customized, but a dependable pipeline will always have to move smoothly from committing code to a successful, error-free deployment.

Building a CI/CD pipeline on DeployHQ step by step

Set up your DeployHQ project

Setting up your CI/CD pipeline should be both quick and intuitive for minimal overhead as all pieces fall into place. Here are the DeployHQ deployment steps you need to get up for your first commit:

  1. First off, you’re going to need DeployHQ account. Make sure you choose the option that best fits your development needs.
  2. Create your first project by clicking on “Projects” and “New Project”. Under “Where is your repository hosted?”, pick your repository host (or add your repository details manually), your time zone, and a possible template you might want to apply.

Choosing a repository host

  1. After you have selected the specific repository you want to connect to your project, it’s time to define your deployment targets. You can pick a server or server group (you can group servers by purpose and assign them to specific workflows).

Building the CI/CD pipeline

  1. When source control is integrated and functioning, move to “Build a pipeline” in your app settings and select “New Command”. Here you can pick a pre-configured build sequence that uses one of the common build tools: NPM, Yarn, Gulp, Grunt, Jekyll, Composer, or Ruby. You can also set your custom command.
  2. Once you have saved your new command, the “Build Configuration” section will provide you with useful features for your build process, such as language versions, package managers, and other dependencies.
  3. For automated testing, run unit and integration tests in your external CI (such as GitHub Actions). Deployment should proceed only upon success.
  4. Deployments can be automated, scheduled, or launched in parallel. You can also tweak deployments as you see fit, for example restricting deployments to specific time windows or configuring deployment triggers. You can also define a config file or SSH commands to run pre- and post-deployment actions (such as clearing caches or run migrations), and assign permissions for whoever can and cannot deploy your applications to certain target servers.

To make your automated pipeline even smoother, DeployHQ supports atomic (zero-downtime) deployments via staging directories and symlink switching. This ensures zero downtime during the actual deployment process. Last but not least, DeployHQ likes all sorts of tech. You can automate the deployment of your project using a wide array of technologies and frameworks.

Best practices for a smooth CI/CD pipeline

  • Use deployment targets as envs: Assign separate dev/staging/production servers, group them by purpose, and/or configure them for different workflows.
  • Templates: Apply consistent build and deployment settings across multiple projects.
  • Deployment availability: Restrict production deployments to specific time windows.
  • Build pipelines: Set up builds and commands to run on DeployHQ’s servers before a deployment starts. Build assets, fetch dependencies, or run tests on your code.
  • Atomic (Zero Downtime) Deployments: Do this if you want to enjoy minimal downtime or avoid it altogether.
  • Rollback feature: Keep past deployments available to instantly revert.
  • Permissions + access control: Assign who can deploy and where.
  • Integrations: Slack/email/webhooks for notifications, so you never miss a failed build/deploy.

Conclusion

A CI/CD pipeline and deployment automation should be set up and then forgotten so that you can focus on building and releasing the best code. DeployHQ cares about your deployments, which is why it offers a stress-free platform with maximum customization. It offers deployment targets, templates, build pipelines, and rollback options that help you deploy with confidence, whether you’re a solo developer or a scaling team.

Find out more about DeployHQ's offer here.

FAQs

What is a CI/CD pipeline?

A CI/CD (Continuous Integration + Continuous Deployment) pipeline is a development approach that supports faster and less error-prone releases. CI automatically integrates code changes into a shared repository and runs automated tests, while CD deploys tested code directly to staging or production environments.

Why should I use DeployHQ for building a CI/CD pipeline?

DeployHQ allows you to build CI/CD pipelines quickly and effortlessly. It integrates with platforms like GitHub, GitLab, and Bitbucket, supports multiple deployment targets, and provides templates to standardize your setup.

Which source code management (SCM) tools does DeployHQ support?

DeployHQ supports popular repositories such as GitHub, CodeBase, GitLab, and Bitbucket.

A little bit about the author

Marta | Software Developer | DeployHQ As a software developer on the DeployHQ team, Marta contributes to building and improving features that help users deploy faster and more reliably. When she's not coding, she enjoys exploring new cuisines and discovering unique flavors.