Skip to content

Conversation

@jakublatkowski
Copy link

This PR adds BaseSemVer to the standard output variables exposed by GitVersion.

Description

This PR adds BaseSemVer to the standard output variables exposed by GitVersion, making it available alongside existing version fields in:

  • Environment variables (e.g., GitVersion_BaseSemVer)
  • JSON output
  • Build agent-specific outputs (Azure Pipelines, GitHub Actions, etc.)

The BaseSemVer represents the base semantic version calculated by GitVersion before any pre-release tags or metadata are applied. This is the foundational version derived from the repository's version tags and configuration.

Related Issue

This PR addresses a feature request for exposing BaseSemVer in output variables.
Resolves #4803

Motivation and Context

The Problem

While GitVersion internally calculates BaseSemVer as a fundamental part of its versioning logic, this value is not currently exposed in the standard output variables. Teams that need access to the base version must either:

  • Parse it from verbose logs
  • Derive it manually from other version outputs
  • Maintain custom scripts with brittle workarounds

Why BaseSemVer Matters

The base semantic version is particularly valuable for:

  1. Incremental Analysis Tools: Systems like SonarCloud require the previous/base version to generate accurate incremental code coverage reports and quality gate comparisons.

  2. Release Comparisons: CI/CD pipelines that need to compare the current build against a baseline version for:

    • Change detection
    • Deployment decisions
    • Rollback strategies
  3. Documentation & Reporting: Generating release notes or reports that reference the underlying semantic version without pre-release suffixes.

  4. Multi-stage Pipelines: Different pipeline stages may need the base version separately from the full semantic version with metadata.

Why This Change is Valuable

By exposing BaseSemVer as a standard output variable, we:

  • Eliminate workarounds: Teams no longer need custom parsing logic
  • Improve consistency: All version components are available through the same interface
  • Enable new integrations: Simplifies integration with tools that need base version information
  • Follow principle of least surprise: If GitVersion calculates it, users should be able to access it

How Has This Been Tested?

Unit Tests: Added/updated tests to verify:

  • BaseSemVer is included in output variable collections
  • Value is correctly propagated to all output channels
  • Backward compatibility with existing outputs

Verification Steps

  • Confirmed BaseSemVer appears in all output formats
  • Verified value matches the internally calculated base version
  • Checked that existing output variables remain unchanged
  • Tested with different GitVersion configuration scenarios

Screenshots (if appropriate):

Example JSON output showing the new BaseSemVer field:

{
  "Major": 5,
  "Minor": 12,
  "Patch": 0,
  "BaseSemVer": "5.12.0",
  "SemVer": "5.12.0-beta.1",
  "FullSemVer": "5.12.0-beta.1+42",
  ...
}

Additional Notes

This change is purely additive - it introduces a new output variable without modifying any existing behavior or outputs. The risk of regression is minimal, and it opens up new integration possibilities for teams using GitVersion in their CI/CD pipelines.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
23.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@jakublatkowski jakublatkowski changed the title Expose BaseSemVer as Output Variable [WIP] Expose BaseSemVer as Output Variable Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant