ThreeMammals/Ocelot · error · Exception

Stable release should happen via CI/CD

Error message

Stable release should happen via CI/CD

What it means

The 'Release' task refuses to create a stable GitHub release when the script is not running inside the CI/CD environment (IsRunningInCICD() is false). This guard prevents developers from accidentally publishing a stable release from a local machine.

Solutions

  1. Run the stable release from the CI/CD pipeline (GitHub Actions) instead of locally.
  2. Verify the CI environment variables that IsRunningInCICD() checks are actually set in your runner.
  3. If you must test locally, use a pre-release/dry-run task rather than the stable release task.
  4. Inspect IsRunningInCICD() and export the expected variable (e.g. GITHUB_ACTIONS=true) only for controlled testing.
Defensive patterns

Strategy: validation

Validate before calling

if (!IsRunningInCICD())
{
    Information("Skipping stable release: not in CI/CD.");
    return;
}

Try / catch

try { RunStableReleaseTask(); }
catch (Exception ex) when (ex.Message.Contains("CI/CD")) { Warning("Stable release must run in CI; use a pre-release task locally."); }

Prevention

When it happens

Trigger: Executing the Release/stable-release Cake task locally (dotnet cake Release) while IsRunningInCICD() detects no CI environment variables (e.g. GITHUB_ACTIONS / TeamCity env vars absent).

Common situations: Developer testing release tasks on a laptop; CI env var renamed so detection fails; running in a container that lacks the CI's environment variables.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of ThreeMammals/Ocelot@d1f22d9304 (2026-09-12). Data as JSON: /api/errors/a4296f2fc287eb73. Report an issue: GitHub.

Appendix: source

Thrown at build.cake:716

		dynamic release = CreateGitHubRelease();
		var path = packagesDir.ToString() + @"/**/*Ocelot.*"; // filter out artifacts.txt and ReleaseNotes.md
		var files = GetFiles(path).ToList();
		foreach (var file in files)
		{
			UploadFileToGitHubRelease(release, file);
		}
		CompleteGitHubRelease(release);
	});

Task("EnsureStableReleaseRequirements")
    .Does(() =>	
    {
		Information("Check if stable release...");

        if (!IsRunningInCICD())
		{
           throw new Exception("Stable release should happen via CI/CD");
		}

		Information("Release is stable...");
	});

Task("DownloadGitHubReleaseArtifacts")
    .Does(async () =>
    {
		try
		{
			// hack to let GitHub catch up, todo - refactor to poll
			System.Threading.Thread.Sleep(5000);
			EnsureDirectoryExists(packagesDir);

			var releaseUrl = "https://api.github.com/repos/ThreeMammals/ocelot/releases/tags/" + versioning.NuGetVersion;
			var releaseInfo = await GetResourceAsync(releaseUrl);
        	var assets_url = Newtonsoft.Json.Linq.JObject.Parse(releaseInfo)
				.Value<string>("assets_url");

View on GitHub (pinned to d1f22d9304)