Skip to content

Add possibility to update build version format for Azure Pipelines task#1591

Merged
arturcic merged 5 commits intoGitTools:vnextfrom
arturcic:feature/updateVersionFormat
Apr 30, 2025
Merged

Add possibility to update build version format for Azure Pipelines task#1591
arturcic merged 5 commits intoGitTools:vnextfrom
arturcic:feature/updateVersionFormat

Conversation

@arturcic
Copy link
Member

@arturcic arturcic commented Apr 30, 2025

This pull request introduces a new configuration option for Azure Pipeline task: buildNumberFormat option which allows to specify the build number format.

Example:

steps:
  # gitversion/setup@3.2.1 task omitted for brevity.

  - task: gitversion/execute@3.2.1
    displayName: Determine Version
    name: version_step # step id used as a reference for output values
    inputs:
      buildNumberFormat: 'v${GitVersion_MajorMinorPatch}' # or 'v$GitVersion_MajorMinorPatch' 

Closes #1434
Closes #1493

Configuration Updates:

  • .azure/ci.yml, .github/workflows/ci.yml, and other YAML files: Replaced update-build-number=false with semantic-version-format=Loose and added the buildNumberFormat input to support custom build number formatting. [1] [2]

Documentation Updates:

  • docs/examples/azure/gitversion/execute.md and docs/examples/github/gitversion/execute.md: Updated examples to reflect the new semantic-version-format configuration and added documentation for the buildNumberFormat option. Examples were renamed for clarity (e.g., "Example 8" to "Output Example 1"). [1] [2] [3]

Test Enhancements:

Replaced "update-build-number=false" with "semantic-version-format=Loose" across various configuration files, tests, and documentation.
Introduced a new method `getExpandedString` to replace placeholders in a string with corresponding environment variable values. This enhancement supports dynamic configuration and improves flexibility when handling patterns with environment variables. Included a debug log for tracing expansions.
Introduced a `buildNumberFormat` option to support customizable build numbers. Updated related logic in `GitVersionTool` and implemented environment variable expansion for the format. Added unit tests to ensure correct behavior when `buildNumberFormat` is provided or omitted.
Renamed workflow and Azure files for clarity and consistency, aligning with related documentation changes. Added "buildNumberFormat" input to Azure configurations and updated corresponding documentation with examples and details.
@arturcic arturcic requested a review from Copilot April 30, 2025 08:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request updates the configuration for GitVersion to support a new semantic versioning format by replacing the old update‑build‑number option with a semantic-version‑format and a new buildNumberFormat input. It also adds enhancements to testing and updates documentation and CI configuration to reflect these changes.

  • Updated GitVersion tool to use buildNumberFormat for build number updates.
  • Modified settings and test files to support and validate the new configuration.
  • Updated documentation and CI workflow files to demonstrate the new configuration and output examples.

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tools/gitversion/tool.ts Added updateBuildNumber method to use custom build number formatting.
src/tools/gitversion/settings.ts Integrated buildNumberFormat input retrieval into settings.
src/tools/gitversion/runner.ts Updated error messaging and invoked updateBuildNumber after parsing.
src/tools/gitversion/models.ts Extended ExecuteSettings to include an optional buildNumberFormat.
src/agents/common/build-agent.ts Added getExpandedString support for environment variable expansion.
Various test files Updated tests to validate buildNumberFormat behavior and consistency.
Documentation and Workflow Files Modified examples to clearly demonstrate new configuration usage.

Sets the build number format to include the major, minor, and patch versions.
This ensures consistent and informative build versioning.
@arturcic arturcic force-pushed the feature/updateVersionFormat branch from 8ac1044 to 81231ee Compare April 30, 2025 18:47
@arturcic arturcic merged commit dcb9dda into GitTools:vnext Apr 30, 2025
8 checks passed
@arturcic arturcic deleted the feature/updateVersionFormat branch April 30, 2025 19:00
@mergify
Copy link
Contributor

mergify bot commented Apr 30, 2025

Thank you @arturcic for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants