gitlab

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

README

GitLab CI/CD Pipelines

Usage

cinzel gitlab -h
Parse HCL to YAML

Convert GitLab-oriented HCL blocks into a single .gitlab-ci.yml file.

cinzel gitlab parse --file ./cinzel/pipeline.hcl --output-directory .
Unparse YAML to HCL

Convert .gitlab-ci.yml (or other GitLab CI YAML) into HCL.

cinzel gitlab unparse --file ./.gitlab-ci.yml --output-directory ./cinzel

Use --dry-run to print generated files to stdout.

HCL shape

stages = ["build", "test", "deploy"]

variable "deploy_env" {
  name        = "DEPLOY_ENV"
  value       = "production"
  description = "Target environment"
}

job "build" {
  stage  = "build"
  image  = "golang:1.26"
  script = ["go build -o app ./..."]
}

job "test" {
  extends    = [template.go_base]
  stage      = "test"
  depends_on = [job.build]
  script     = ["go test ./..."]

  rule {
    if   = "$${CI_PIPELINE_SOURCE} == \"merge_request_event\""
    when = "on_success"
  }
}

workflow {
  rule {
    if   = "$${CI_COMMIT_BRANCH} == \"main\""
    when = "always"
  }
}

include {
  local = ".gitlab/base.yml"
}

default {
  image = "alpine:3.20"

  service {
    name  = "postgres:16"
    alias = "db"
  }
}

template "go_base" {
  image = "golang:1.26"
}

Notes

  • HCL uses depends_on; YAML uses needs:.
  • $${VAR} in HCL becomes ${VAR} in YAML.
  • ${VAR} in YAML becomes $${VAR} in HCL output.
  • Parse output is one file: .gitlab-ci.yml in the selected output directory.
  • Parse output includes cinzel provider markers in YAML headers (generated-by and cinzel-provider).
  • template.<id> and job.<id> references in extends map to YAML extends entries.
  • Repeated include {} blocks map to YAML include: entries.
  • Repeated service {} blocks map to YAML services: entries under default or a job.
  • Parse schema is defined by typed HCL structs in provider/gitlab/config.go; hcl:",remain" is used only for intentional pass-through islands.
  • Unparse schema validation favors strict typed YAML decode over manual key allowlist tables.

Documentation

Overview

Copyright 2026 YLD Limited SPDX-License-Identifier: Apache-2.0 Package gitlab provides a GitLab CI/CD provider implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitLab

type GitLab struct{}

GitLab is the provider implementation for GitLab CI/CD pipelines.

func New

func New() *GitLab

New returns a new GitLab provider instance.

func (*GitLab) GetDescription

func (p *GitLab) GetDescription() string

GetDescription returns a human-readable provider description.

func (*GitLab) GetParseDescription

func (p *GitLab) GetParseDescription() string

GetParseDescription returns a parse operation description.

func (*GitLab) GetProviderName

func (p *GitLab) GetProviderName() string

GetProviderName returns the provider identifier.

func (*GitLab) GetUnparseDescription

func (p *GitLab) GetUnparseDescription() string

GetUnparseDescription returns an unparse operation description.

func (*GitLab) Parse

func (p *GitLab) Parse(opts provider.ProviderOps) error

Parse converts HCL pipeline definitions to GitLab YAML.

func (*GitLab) Unparse

func (p *GitLab) Unparse(opts provider.ProviderOps) error

Unparse converts GitLab YAML to HCL pipeline definitions.

type PipelineYAMLFile

type PipelineYAMLFile struct {
	Filename string
	Content  map[string]any
}

PipelineYAMLFile pairs the output filename with pipeline YAML content.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL