Skip to content
.Base.gitlab-ci.yml 2.24 KiB
Newer Older
# This template is a port of the OpenTofu CI/CD component at
# https://gitlab.com/components/opentofu
# It is generated with the `make backports` command from that project.
#
# Please make sure to use the component when your project is hosted on GitLab.com
# or when you are willing to mirror the component project into your self-managed
# instance and use it from there.
#
# Attention: This template will be removed in favor of the OpenTofu CI/CD component as soon as components
#            are available for self-managed instances.
#
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/OpenTofu/Base.gitlab-ci.yml

variables:
  # OpenTofu CI/CD component version, see https://gitlab.com/components/opentofu/-/releases
  VERSION: "0.1.0"
  # Compatible OpenTofu version, see https://gitlab.com/components/opentofu/-/releases
  OPENTOFU_VERSION: "1.6.0"
  # Job Image with `gitlab-tofu`
  GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE: $CI_REGISTRY/components/opentofu
  # The relative path to the root directory of the OpenTofu project
Timo Furrer's avatar
Timo Furrer committed
  TF_ROOT: ${CI_PROJECT_DIR}
  # The name of the state file used by the GitLab Managed Terraform state backend
  TF_STATE_NAME: default
Timo Furrer's avatar
Timo Furrer committed

Timo Furrer's avatar
Timo Furrer committed
.opentofu:use-component-instead-of-template:
Timo Furrer's avatar
Timo Furrer committed
  stage: validate
  needs: []
  allow_failure: true
  rules:
Timo Furrer's avatar
Timo Furrer committed
    - if: '$CI_SERVER_HOST == "gitlab.com"'
Timo Furrer's avatar
Timo Furrer committed
  image: alpine:3.19
  script:
    - |
      echo "You are using the OpenTofu CI/CD template on GitLab.com which is not recommended."
      echo "This template is available for self-managed customers until CI/CD components are available to them and it will be removed asap."
      echo " "
Timo Furrer's avatar
Timo Furrer committed
      echo "We recommed that you migrate to the OpenTofu CI/CD component instead."
      echo "The OpenTofu CI/CD component with a default configuration can be included as follows:"
      echo " "
Timo Furrer's avatar
Timo Furrer committed
      echo "include:"
      echo "  - component: gitlab.com/components/opentofu/full-pipeline@0.1.0"
      echo "    inputs:"
      echo "      version: latest"
      echo "      opentofu_version: 1.6.0"
      echo ""
Timo Furrer's avatar
Timo Furrer committed
      echo "stages: [validate, test, build, deploy]"
      echo " "
Timo Furrer's avatar
Timo Furrer committed
      echo "You can read about more about the OpenTofu CI/CD component here:"
      echo "https://gitlab.com/components/opentofu"
Timo Furrer's avatar
Timo Furrer committed
    - 'false'