TedToolkit.CiContext.GitLab 2026.8.14

dotnet add package TedToolkit.CiContext.GitLab --version 2026.8.14
                    
NuGet\Install-Package TedToolkit.CiContext.GitLab -Version 2026.8.14
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TedToolkit.CiContext.GitLab" Version="2026.8.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TedToolkit.CiContext.GitLab" Version="2026.8.14" />
                    
Directory.Packages.props
<PackageReference Include="TedToolkit.CiContext.GitLab" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TedToolkit.CiContext.GitLab --version 2026.8.14
                    
#r "nuget: TedToolkit.CiContext.GitLab, 2026.8.14"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TedToolkit.CiContext.GitLab@2026.8.14
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TedToolkit.CiContext.GitLab&version=2026.8.14
                    
Install as a Cake Addin
#tool nuget:?package=TedToolkit.CiContext.GitLab&version=2026.8.14
                    
Install as a Cake Tool

TedToolkit.CiContext.GitLab

TedToolkit.CiContext.GitLab provides strongly typed, phase-aware, on-demand access to GitLab CI/CD variables in the current process environment while keeping its public API in the concise TedToolkit.GitLab namespace.

Install

dotnet add package TedToolkit.CiContext.GitLab

Quick Start

using TedToolkit.GitLab;

if (GitLabCi.PrePipeline.General.Detected is true)
{
    Console.WriteLine($"Project: {GitLabCi.PrePipeline.Project.Path}");
    Console.WriteLine($"Pipeline: {GitLabCi.JobOnly.Pipeline.Id}");
    Console.WriteLine($"Working directory: {GitLabCi.JobOnly.Project.Dir}");
}

No context needs to be created. GitLabCi, each availability phase, and every domain or official category are nested static classes. A terminal property reads its environment variable when accessed.

GitLab variable C# property Type
CI_PROJECT_ID GitLabCi.PrePipeline.Project.Id long?
CI_COMMIT_TIMESTAMP GitLabCi.PrePipeline.Commit.Timestamp DateTimeOffset?
CI_JOB_TIMEOUT GitLabCi.JobOnly.Job.Timeout TimeSpan?
CI_PROJECT_URL GitLabCi.PrePipeline.Project.Url Uri?
CI_PROJECT_DIR GitLabCi.JobOnly.Project.Dir DirectoryPath?
CI_SERVER_TLS_CA_FILE GitLabCi.Pipeline.Server.TlsCaFile FilePath?
CI_PIPELINE_SOURCE GitLabCi.PrePipeline.Pipeline.Source GitLabPipelineSource?
CI_PIPELINE_IID GitLabCi.Pipeline.Iid long?
CI_RUNNER_TAGS GitLabCi.JobOnly.Runner.Tags IReadOnlyList<string>?
CI_JOB_TOKEN GitLabCi.JobOnly.Job.Token CiSecret<string>?
CI_RUNNER_SHORT_TOKEN GitLabCi.JobOnly.Runner.ShortToken CiSecret<string>?

Official relationships remain visible in paths such as GitLabCi.PrePipeline.MergeRequest.Source.BranchName, GitLabCi.ExternalPullRequest.Target.BranchSha, and GitLabCi.JobOnly.Integrations.Harbor.Url.

Live Process Values

Each access reads the current process environment. No full-environment snapshot, raw dictionary, or navigation object is allocated:

string? before = GitLabCi.PrePipeline.Commit.Sha;

Environment.SetEnvironmentVariable("CI_COMMIT_SHA", "updated");

string? after = GitLabCi.PrePipeline.Commit.Sha; // "updated"

GitLab Runner supplies stable variables to a job process. Tests or tools that mutate process environment variables must run those mutations serially and restore previous values afterward.

Missing And Malformed Values

A variable that GitLab did not provide returns null, which is normal because availability depends on the pipeline type and phase.

When a present value does not match its documented type, the typed property throws FormatException. The current text remains available for diagnosis:

string? rawProjectId = CiEnvironment.GetRawValue("CI_PROJECT_ID");

// Accessing GitLabCi.PrePipeline.Project.Id throws FormatException
// when CI_PROJECT_ID is present but is not a documented numeric ID.

Sensitive Values

Credentials and authentication-capable tokens use the shared CiSecret<string>. ToString() shows only the final four characters for generated values of at least 12 characters and fully redacts shorter values; call Reveal() only where the credential is required:

string? token = GitLabCi.JobOnly.Job.Token?.Reveal();

CI_TRIGGER_SHORT_TOKEN remains a plain string because GitLab defines it as a four-character display fragment rather than an authentication value.

CiEnvironment.GetRawValue(...) can return sensitive original values. Do not log its result without applying the appropriate secret-handling policy.

Custom And Future Variables

The typed surface covers every explicitly named variable in the current official GitLab predefined variable documentation. Project, group, instance, deployment-specific, and newly introduced variables remain available without a library update:

string? region = CiEnvironment.GetRawValue("DEPLOY_REGION");

Use reflection over static terminal properties carrying CiVariableAttribute when tooling needs the exact environment name, and read GitLabCiVariableCategoryAttribute for the official documentation category. Read GitLabCiVariableAvailabilityAttribute from PrePipeline, Pipeline, or JobOnly when tooling needs the official phase. ExternalPullRequest is a direct root category without availability metadata because GitLab does not assign those variables to one of the three phases.

Target Frameworks

net6.0, net7.0, net8.0, net9.0, net10.0, net472, net48, netstandard2.0, and netstandard2.1.

License

Licensed under LGPL-3.0.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.8.14 112 8/14/2026