Skip to main content
Welcome. This site supports keyboard navigation and screen readers. Press ? at any time for keyboard shortcuts. Press [ to focus the sidebar, ] to focus the content. High-contrast themes are available via the toolbar.
serard@dev00:~/cv

All Generated Model Classes

# Class Source Properties Role
1 GitLabCiFile Root emitter 12 + Jobs + Extensions Pipeline root container
2 GitLabCiJob job definition 30+ Concrete job definition
3 GitLabCiJobTemplate job_template definition 30+ Base job (inherited by Job)
4 GitLabCiArtifacts artifacts definition 9 Build output configuration
5 GitLabCiArtifactsReports artifacts.reports inline 10+ JUnit, coverage, SAST reports
6 GitLabCiDefault default definition 8 Default job settings
7 GitLabCiWorkflow workflow definition 3 Pipeline-level rules
8 GitLabCiWorkflowAutoCancel workflow.auto_cancel inline 2 Auto-cancel config
9 GitLabCiSpec spec root property 1 Pipeline inputs spec
10 GitLabCiBaseInput base_input definition 5+ Input parameter definition
11 GitLabCiHooks hooks definition 1 Pre-get-sources scripts
12 GitLabCiCacheItem cache_item definition 5 Cache layer config
13 GitLabCiCacheItemKeyConfig cache.key inline 3 Cache key config
14 GitLabCiJobTemplateNeedsConfig needs inline object 4 Job dependency (DAG)
15 GitLabCiJobTemplateEnvironmentConfig environment inline 7 Deployment target
16 GitLabCiJobTemplateEnvironmentConfigKubernetes environment.kubernetes 3 K8s config
17 GitLabCiJobTemplateEnvironmentConfigKubernetesManagedResources Deep inline 2 K8s resources
18 GitLabCiJobTemplateEnvironmentConfigKubernetesDashboard Deep inline 2 K8s dashboard
19 GitLabCiJobTemplateRelease release definition 5 Release creation
20 GitLabCiJobTemplateReleaseAssets release.assets inline 1 Release assets
21 GitLabCiJobTemplateReleaseAssetsLinksItem assets.links[] inline 4 Asset link
22 GitLabCiJobTemplateTriggerConfig trigger inline 4 Downstream pipeline
23 GitLabCiJobTemplateTriggerConfigForward trigger.forward inline 2 Variable forwarding
24 GitLabCiJobTemplateInherit inherit definition 2 Config inheritance
25 GitLabCiStepExec step_exec definition 1 Step execution
26 GitLabCiStepGitReference step_git_reference definition 1 Git step
27 GitLabCiStepGitReferenceGit step.git inline 2+ Git source
28 GitLabCiStepOciReference step_oci_reference definition 1 OCI step
29 GitLabCiStepOciReferenceOci step.oci inline 2+ OCI source
30 GitLabCiSchemaVersions Version emitter Static Version metadata

GitLab CI Concept to C# Type Mapping

GitLab CI Concept YAML Key C# Type Notes
Pipeline root (file) GitLabCiFile Container for all pipeline config
Stages stages: List<object>? Untyped per schema
Jobs arbitrary keys Dictionary<string, GitLabCiJob>? Flat root mapping
Script script: List<string>? String-or-list handled by converter
Run (Steps) run: List<object>? Alternative to script (18.5+)
Image image: string? Docker image
Services services: List<object>? Additional Docker services
Variables variables: Dictionary<string, object?>? Key-value pairs
Artifacts artifacts: GitLabCiArtifacts? Build outputs
Cache cache: List<object>? Cache layers
Rules rules: List<object>? Conditional execution
Needs needs: List<GitLabCiJobTemplateNeedsConfig>? DAG dependencies
Environment environment: GitLabCiJobTemplateEnvironmentConfig? Deploy target
Release release: GitLabCiJobTemplateRelease? Release creation
Trigger trigger: GitLabCiJobTemplateTriggerConfig? Downstream pipeline
Default default: GitLabCiDefault? Default job config
Workflow workflow: GitLabCiWorkflow? Pipeline-level rules
Include include: object? External YAML inclusion
Tags tags: List<object>? Runner selection
When when: string? Execution condition
Allow Failure allow_failure: bool? Continue on failure
Timeout timeout: string? Job timeout
Dependencies dependencies: List<string>? Legacy artifact downloads
Extends extends: List<string>? Template inheritance
Coverage coverage: string? Coverage regex
Resource Group resource_group: string? Concurrency limit

Fluent Builder API

Every generated model class comes with a corresponding builder that provides fluent construction with per-property validation.

Basic Usage

var result = await new GitLabCiFileBuilder()
    .WithStages(new List<object> { "build", "test", "deploy" })
    .WithVariables(new Dictionary<string, object?>
    {
        ["DOTNET_VERSION"] = "9.0",
        ["CONFIGURATION"] = "Release"
    })
    .WithJob("build", job => job
        .WithImage("mcr.microsoft.com/dotnet/sdk:9.0")
        .WithScript(new List<string>
        {
            "dotnet restore",
            "dotnet build -c $CONFIGURATION"
        })
        .WithArtifacts(new GitLabCiArtifacts
        {
            Paths = new List<string> { "bin/", "obj/" }
        }))
    .WithJob("test", job => job
        .WithImage("mcr.microsoft.com/dotnet/sdk:9.0")
        .WithScript(new List<string> { "dotnet test --logger trx" })
        .WithArtifacts(new GitLabCiArtifacts
        {
            Reports = new GitLabCiArtifactsReports
            {
                Junit = new List<string> { "junit.xml" },
                CoverageReport = new List<string> { "coverage/cobertura.xml" }
            }
        }))
    .BuildAsync();

var ciFile = result.ValueOrThrow().Resolved();

Inline Dictionary Builder

For dictionaries, you can use a callback-based builder:

builder.WithVariables(vars => vars
    .With("NODE_ENV", "production")
    .With("DOCKER_TLS_CERTDIR", "")
    .With("CI_DEBUG_TRACE", "false"))

Single Job Builder

The WithJob method provides a convenient shorthand for adding individual jobs:

builder
    .WithJob("build", job => job
        .WithImage("node:20")
        .WithScript(new List<string> { "npm ci", "npm run build" }))
    .WithJob("test", job => job
        .WithScript(new List<string> { "npm test" })
        .WithArtifacts(new GitLabCiArtifacts
        {
            Reports = new GitLabCiArtifactsReports
            {
                Junit = new List<string> { "test-results.xml" }
            }
        }))
    .WithJob("deploy", job => job
        .WithScript(new List<string> { "echo Deploying..." })
        .WithWhen("manual")
        .WithEnvironment(new GitLabCiJobTemplateEnvironmentConfig
        {
            Name = "production",
            Url = "https://app.example.com"
        }))

Custom Validation

Builders generate virtual Validate*() methods that can be overridden for custom validation:

public class StrictPipelineBuilder : GitLabCiFileBuilder
{
    protected override IEnumerable<Exception>? ValidateStages(
        List<object>? value)
    {
        if (value is null || value.Count == 0)
            yield return new InvalidOperationException(
                "Pipeline must define at least one stage.");
    }

    protected override IEnumerable<Exception>? ValidateJobs(
        Dictionary<string, GitLabCiJob>? value)
    {
        if (value is null || value.Count == 0)
            yield return new InvalidOperationException(
                "Pipeline must define at least one job.");
    }
}

Result-Based Building

The BuildAsync() method returns a Result<T>, not a raw object. Validation errors are collected, not thrown:

var result = await new StrictPipelineBuilder()
    .WithStages(new List<object>()) // Empty — will fail validation
    .BuildAsync();

if (!result.IsSuccess)
{
    foreach (var error in result.Errors)
        Console.WriteLine($"Validation error: {error}");
}
else
{
    var ciFile = result.ValueOrThrow().Resolved();
    var yaml = GitLabCiYamlWriter.Serialize(ciFile);
}
Diagram
The builder collects With calls, then BuildAsync funnels through ValidateAsync and returns a Result that either carries errors or yields a GitLabCiFile via ValueOrThrow().Resolved().

⬇ Download