Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch environment variable randomly does not get populated #1035

Closed
sparx2206 opened this issue Feb 8, 2024 · 7 comments · Fixed by #1054
Closed

Patch environment variable randomly does not get populated #1035

sparx2206 opened this issue Feb 8, 2024 · 7 comments · Fixed by #1054

Comments

@sparx2206
Copy link

Hi,

since the latest version we are experiencing a strange RANDOM behavior in gitversion/execute@0 task.

The output of the task correctly lists value of the Patch version
image

However, when we list environment variables to the machine, all the PATCH variables are empty:
image

As stated above, this happens randomly, rerun sometimes fixes this.

@arturcic
Copy link
Member

arturcic commented Feb 8, 2024

In your example, the Patch has the value '0' and probably that is the problem, it does but get set in the environment variable

@sparx2206
Copy link
Author

This wasn't an issue until now, and as mentioned, it is random.

@RafVandesande
Copy link

I have the same issue since the 0.11.0 release. Not an issue with 0.10.2.

@jknappett
Copy link

jknappett commented Feb 8, 2024

Experiencing this as well.
Unable to find any contributing factors determining success/failure.

@marc-pe
Copy link

marc-pe commented Feb 29, 2024

I can confirm that it doesn't matter which variable contains value 0. I saw it in Minor before and in this case in both Patch and UncommittedChanges.
Also experiencing this at random. Rerunning the same Build job (without code changes) resolves the issue.

It seems as it uses the same logic as NULL and "" (empty string) now. See Patch, BuildMetaData and BuildMetaDataPadded as examples.

Release 0.11.0

{
  "Major": 2,
  "Minor": 1,
  "Patch": 0,
  "BuildMetaData": null,
  "BuildMetaDataPadded": "",
  "FullBuildMetaData": "Branch.pull-1502-merge.Sha.54a788de07b6e63151fcba11361f58320bed2998",
  "MajorMinorPatch": "2.1.0",
  "SemVer": "2.1.0-PullRequest1502.53",
  "LegacySemVer": "2.1.0-PullRequest1502-53",
  "LegacySemVerPadded": "2.1.0-PullRequest1502-0053",
  "AssemblySemVer": "2.1.0.0",
  "AssemblySemFileVer": "2.1.0.0",
  "FullSemVer": "2.1.0-PullRequest1502.53",
  "InformationalVersion": "2.1.0-PullRequest1502.53+Branch.pull-1502-merge.Sha.54a788de07b6e63151fcba11361f58320bed2998",
  "BranchName": "pull/1502/merge",
  "EscapedBranchName": "pull-1502-merge",
  "Sha": "54a788de07b6e63151fcba11361f58320bed2998",
  "ShortSha": "54a788d",
  "NuGetVersionV2": "2.1.0-pullrequest1502-0053",
  "NuGetVersion": "2.1.0-pullrequest1502-0053",
  "NuGetPreReleaseTagV2": "pullrequest1502-0053",
  "NuGetPreReleaseTag": "pullrequest1502-0053",
  "VersionSourceSha": "8e52635345050c89f012521eefe8a4a3ca2b0c2a",
  "CommitsSinceVersionSource": 53,
  "CommitsSinceVersionSourcePadded": "0053",
  "UncommittedChanges": 0,
  "CommitDate": "2024-02-29"
}
GITVERSION_ASSEMBLYSEMFILEVER=2.1.0.0
GITVERSION_ASSEMBLYSEMVER=2.1.0.0
GITVERSION_BRANCHNAME=pull/1502/merge
GITVERSION_BUILDMETADATA=
GITVERSION_BUILDMETADATAPADDED=
GITVERSION_COMMITDATE=2024-02-29
GITVERSION_COMMITSSINCEVERSIONSOURCE=53
GITVERSION_COMMITSSINCEVERSIONSOURCEPADDED=0053
GITVERSION_ESCAPEDBRANCHNAME=pull-1502-merge
GITVERSION_FULLBUILDMETADATA=Branch.pull-1502-merge.Sha.54a788de07b6e63151fcba11361f58320bed2998
GITVERSION_FULLSEMVER=2.1.0-PullRequest1502.53
GITVERSION_INFORMATIONALVERSION=2.1.0-PullRequest1502.53+Branch.pull-1502-merge.Sha.54a788de07b6e63151fcba11361f58320bed2998
GITVERSION_LEGACYSEMVER=2.1.0-PullRequest1502-53
GITVERSION_LEGACYSEMVERPADDED=2.1.0-PullRequest1502-0053
GITVERSION_MAJOR=2
GITVERSION_MAJORMINORPATCH=2.1.0
GITVERSION_MINOR=1
GITVERSION_NUGETPRERELEASETAG=pullrequest1502-0053
GITVERSION_NUGETPRERELEASETAGV2=pullrequest1502-0053
GITVERSION_NUGETVERSION=2.1.0-pullrequest1502-0053
GITVERSION_NUGETVERSIONV2=2.1.0-pullrequest1502-0053
GITVERSION_PATCH=
GITVERSION_PRERELEASELABEL=PullRequest1502
GITVERSION_PRERELEASELABELWITHDASH=-PullRequest1502
GITVERSION_PRERELEASENUMBER=53
GITVERSION_PRERELEASETAG=PullRequest1502.53
GITVERSION_PRERELEASETAGWITHDASH=-PullRequest1502.53
GITVERSION_SEMVER=2.1.0-PullRequest1502.53
GITVERSION_SHA=54a788de07b6e63151fcba11361f58320bed2998
GITVERSION_SHORTSHA=54a788d
GITVERSION_UNCOMMITTEDCHANGES=
GITVERSION_VERSIONSOURCESHA=8e52635345050c89f012521eefe8a4a3ca2b0c2a
GITVERSION_WEIGHTEDPRERELEASENUMBER=30053

Release 0.10.2

{
  "Major": 2,
  "Minor": 1,
  "Patch": 0,
  "PreReleaseTag": "alpha.47",
  "PreReleaseTagWithDash": "-alpha.47",
  "PreReleaseLabel": "alpha",
  "PreReleaseLabelWithDash": "-alpha",
  "PreReleaseNumber": 47,
  "WeightedPreReleaseNumber": 47,
  "BuildMetaData": null,
  "BuildMetaDataPadded": "",
  "FullBuildMetaData": "Branch.develop.Sha.62b349a2b409a166fbc65370ee35269611f05a35",
  "MajorMinorPatch": "2.1.0",
  "SemVer": "2.1.0-alpha.47",
  "LegacySemVer": "2.1.0-alpha47",
  "LegacySemVerPadded": "2.1.0-alpha0047",
  "AssemblySemVer": "2.1.0.0",
  "AssemblySemFileVer": "2.1.0.0",
  "FullSemVer": "2.1.0-alpha.47",
  "InformationalVersion": "2.1.0-alpha.47+Branch.develop.Sha.62b349a2b409a166fbc65370ee35269611f05a35",
  "BranchName": "develop",
  "EscapedBranchName": "develop",
  "Sha": "62b349a2b409a166fbc65370ee35269611f05a35",
  "ShortSha": "62b349a",
  "NuGetVersionV2": "2.1.0-alpha0047",
  "NuGetVersion": "2.1.0-alpha0047",
  "NuGetPreReleaseTagV2": "alpha0047",
  "NuGetPreReleaseTag": "alpha0047",
  "VersionSourceSha": "8e52635345050c89f012521eefe8a4a3ca2b0c2a",
  "CommitsSinceVersionSource": 47,
  "CommitsSinceVersionSourcePadded": "0047",
  "UncommittedChanges": 0,
  "CommitDate": "2024-01-31"
}
GITVERSION_ASSEMBLYSEMFILEVER=2.1.0.0
GITVERSION_ASSEMBLYSEMVER=2.1.0.0
GITVERSION_BRANCHNAME=develop
GITVERSION_BUILDMETADATA=
GITVERSION_BUILDMETADATAPADDED=
GITVERSION_COMMITDATE=2024-01-31
GITVERSION_COMMITSSINCEVERSIONSOURCE=47
GITVERSION_COMMITSSINCEVERSIONSOURCEPADDED=0047
GITVERSION_ESCAPEDBRANCHNAME=develop
GITVERSION_FULLBUILDMETADATA=Branch.develop.Sha.62b349a2b409a166fbc65370ee35269611f05a35
GITVERSION_FULLSEMVER=2.1.0-alpha.47
GITVERSION_INFORMATIONALVERSION=2.1.0-alpha.47+Branch.develop.Sha.62b349a2b409a166fbc65370ee35269611f05a35
GITVERSION_LEGACYSEMVER=2.1.0-alpha47
GITVERSION_LEGACYSEMVERPADDED=2.1.0-alpha0047
GITVERSION_MAJOR=2
GITVERSION_MAJORMINORPATCH=2.1.0
GITVERSION_MINOR=1
GITVERSION_NUGETPRERELEASETAG=alpha0047
GITVERSION_NUGETPRERELEASETAGV2=alpha0047
GITVERSION_NUGETVERSION=2.1.0-alpha0047
GITVERSION_NUGETVERSIONV2=2.1.0-alpha0047
GITVERSION_PATCH=0
GITVERSION_PRERELEASELABEL=alpha
GITVERSION_PRERELEASELABELWITHDASH=-alpha
GITVERSION_PRERELEASENUMBER=47
GITVERSION_PRERELEASETAG=alpha.47
GITVERSION_PRERELEASETAGWITHDASH=-alpha.47
GITVERSION_SEMVER=2.1.0-alpha.47
GITVERSION_SHA=62b349a2b409a166fbc65370ee35269611f05a35
GITVERSION_SHORTSHA=62b349a
GITVERSION_UNCOMMITTEDCHANGES=0
GITVERSION_VERSIONSOURCESHA=8e52635345050c89f012521eefe8a4a3ca2b0c2a
GITVERSION_WEIGHTEDPRERELEASENUMBER=47
GIT_TERMINAL_PROMPT=0

@arturcic
Copy link
Member

@Amasis thanks for the examples, I will check the code that sets these env vars. The change should be done here

public writeGitVersionToAgent(gitversion: GitVersionOutput): void {

@arturcic
Copy link
Member

It seems like in azure pipelines the 0 values gets discarded https://github.com/microsoft/azure-pipelines-task-lib/blob/4ee6f874499c3b5cfc599871f91cb52b3a3fcd23/node/task.ts#L214. We use the lib in our code.

I think you should check for the empty value and replace with 0 as that's the only value it can have as it's a number

@arturcic arturcic closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
@arturcic arturcic reopened this Mar 2, 2024
arturcic added a commit to arturcic/gittools-actions that referenced this issue Mar 2, 2024
arturcic added a commit that referenced this issue Mar 2, 2024
#1035 - fix the way value '0' is set in output and environment variables
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 a pull request may close this issue.

5 participants