Skip to content

How to add a CI/CD component to the Unified DevOps platform

This guide covers how to bootstrap a new CI/CD component for the Unified DevOps platform using our copier template.

Read the documentation

Make sure you have read through both the best practice guide and the copier template README to familiarise yourself with our CI/CD component conventions.

Create the GitLab project

In the unified-devops-platform.tfvars file within the GitLab project factory, add a new CI/CD component project. For example:

projects = {
  # ...

  "ci-components/pre-commit" = {
    subgroup = "ci-components"
    path     = "pre-commit"

    display_name = "Pre-commit Hook Components"
    description  = <<-EOI
      GitLab CI/CD components for running pre-commit hooks in CI pipelines
    EOI

    ast_enable_mr_pipelines = true

    cicd_catalog_enabled = true

    container_expiration_policy = {
      cadence         = "1d"
      enabled         = true
      keep_n          = 1
      name_regex_keep = "[0-9]+\\.[0-9]+\\.[0-9]+"
      older_than      = "7d"
    }
  }
}

Note

It is good practice to add a container expiration policy if your component will build a container image to run jobs in. If your component is not building any containers, feel free to omit the expiration policy.

Initialise the copier template

Close the empty project locally and apply the copier template:

$ COMPONENT_PROJECT_NAME=... # replace with project name of component
$ TEMPLATE_REF=... # replace with most recent release of uis/devops/platform/ci-components/template
$ git clone git@gitlab.developers.cam.ac.uk:uis/devops/platform/ci-components/$COMPONENT_PROJECT_NAME
$ copier copy --vcs-ref "$TEMPLATE_REF" \
    https://gitlab.developers.cam.ac.uk/uis/devops/platform/ci-components/template.git \
    "$COMPONENT_PROJECT_NAME"

Answer the template questions when prompted.

Develop and release the component

Develop and test the component following best practice.

Important

You must make at least one release before the component becomes available in the CI/CD component catalogue.

Your component must be in the component catalogue to be include-ed using semantic versioning.

Summary

In this how-to guide you learned how to bootstrap a new GitLab CI/CD component for the Unified DevOps platform.

Next steps