Skip to content

[ISSUE]: Using environment variable with label can produce Semver incompatible labels #5009

Description

@robertcoltheart

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.Tool

GitVersion version

6.8.0

Operating system

N/A

What are you seeing?

If I use GITHUB_HEAD_REF as an environment variable for labels, it can produce labels that have '/' in them which is not compliant with Semver pre-release labels (which should be A-Z, a-z, 0-9 and '-').

This is not the case when using {BranchName} as a label, which sanitizes the output correctly, and is specific to environment variables.

What is expected?

The label should be generated with correct and valid charaacters.

eg.

export GITHUB_HEAD_REF="feature/my-branch"

# Correct
{env:GITHUB_HEAD_REF} => 'feature-my-branch'

# Incorrect
{env:GITHUB_HEAD_REF} => 'feature/my-branch'

Steps to Reproduce

Use env:MY_VAR when the variable contains slashes or other non-compliant characters for label formatting.

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions