Skip to content

Enable use of GitVersion variables in the VSO BuildNumber #689

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

Merged
merged 12 commits into from
Oct 14, 2015

Conversation

clairernovotny
Copy link

As discussed in #663, this lets the VSO BuildNumber control placement and use of the GitVersion variables in the build number.

Just put $(GitVersion_Foo) wherever you want in the VSO build number and the agent task will replace that with the actual version.

@@ -37,6 +37,12 @@ The VSO build step updates the build number automatically to the GitVersion numb
GitVersion passes variables in the form of `GitVersion.*` (Eg: `GitVersion.Major`) to TFS Build and also writes `GITVERSION_*` (Eg: `GITVERSION_MAJOR`) environment variables that are available for any subsequent build step.
See [Variables](/more-info/variables/) for an overview of available variables.


#### Using GitVersion variables in build build name
Copy link
Member

Choose a reason for hiding this comment

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

Small typo: build build


#### Using GitVersion variables in build build name
To use GitVersion's variables in the build name, just add them in the form `$(GITVERSION_FullSemVer)` into the Build definition's build number string. Then just ensure GitVersion is called with
`/output buildserver` and it will replace those variables with the calculated version.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe mentioning that the TFS Build task takes care of that (/output buildserver) might be helpful

[Test]
public void Develop_branch()
{
SetEnvironmentVariableForTest();
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to call SetEnvironmentVariableForTest in a Setup method (since they are also around all the time in the build server)?

To use GitVersion's variables in the build name, just add them in the form `$(GITVERSION_FullSemVer)` into the Build definition's build number string. Then just ensure GitVersion is called with
`/output buildserver` and it will replace those variables with the calculated version.
The TFS GitVersion Build Step (above) handles this too, so if you're already using that, there's nothing extra to configure.

Copy link
Member

Choose a reason for hiding this comment

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

A note about how the $(rev:r) variable behaves might be useful, since it most probably wont to what the user expects. It increases every time as long as the version number expanded at build start is the same. Which is always true for the $(GITVERSION_*) variables.

@JakeGinnivan
Copy link
Contributor

@pascalberger i will leave this one to you

@JakeGinnivan
Copy link
Contributor

merge when happy

pascalberger added a commit that referenced this pull request Oct 14, 2015
Enable use of GitVersion variables in the VSO BuildNumber
@pascalberger pascalberger merged commit 6378553 into GitTools:master Oct 14, 2015
@pascalberger
Copy link
Member

Thanks again @onovotny. Nice stuff.

@pascalberger
Copy link
Member

@JakeGinnivan What do you think where would be the best place to mention this change in behavior of the TFS task? Somewhere in the release notes or the breaking changes document? Should we also do for 3.2

@clairernovotny
Copy link
Author

Thank! Any chance of getting a 3.2.1 release out today with this? It'd also help narrow the gap of ppl discovering/using the 3.2.0 behavior.

@pascalberger
Copy link
Member

+1 for a quick release. #687 might also be ready for merging and be included in this release. @JakeGinnivan What do you think?

@JakeGinnivan
Copy link
Contributor

Will do it this morning, was busy yesterday and was out last night.

Sent from my Windows Phone


From: Pascal Bergermailto:[email protected]
Sent: ‎14/‎10/‎2015 11:25 PM
To: GitTools/GitVersionmailto:[email protected]
Cc: Jake Ginnivanmailto:[email protected]
Subject: Re: [GitVersion] Enable use of GitVersion variables in the VSO BuildNumber (#689)

+1 for a quick release. #687#687 might also be ready for merging and be included in this release. @JakeGinnivanhttps://github.com/JakeGinnivan What do you think?


Reply to this email directly or view it on GitHubhttps://github.com//pull/689#issuecomment-148083907.

@clairernovotny
Copy link
Author

@JakeGinnivan how's this looking for a build? :)

@JakeGinnivan
Copy link
Contributor

Today, had a busy week :)

Sent from my Windows Phone


From: Oren Novotnymailto:[email protected]
Sent: ‎16/‎10/‎2015 8:30 PM
To: GitTools/GitVersionmailto:[email protected]
Cc: Jake Ginnivanmailto:[email protected]
Subject: Re: [GitVersion] Enable use of GitVersion variables in the VSO BuildNumber (#689)

@JakeGinnivanhttps://github.com/JakeGinnivan how's this looking for a build? :)


Reply to this email directly or view it on GitHubhttps://github.com//pull/689#issuecomment-148704389.

@clairernovotny
Copy link
Author

🍻

@clairernovotny clairernovotny deleted the vso-build-name branch October 17, 2015 00:31
@JoeBrockhaus
Copy link

JoeBrockhaus commented Dec 7, 2016

I'm finding some inconsistent behavior with this functionality today.

In almost every other instance, the use of the underscore in VSO-PowerShell variable syntax ($(my_variable)) is not standard - instead, the underscore is used only when those variables are transposed to ENV variables (ie: $(Build.Number) == BUILD_NUMBER, and $(Build_Number) would never work).

Over and above this issue of platform consistency (ie: dot vs underscore syntax), $(GitVersion.NuGetVersion) and $(GitVersion_NuGetVersion) (in the least) provide different values altogether: mj.mn.rr-unstable.xx & mj.mn.rr-unstablexxxx respectively.

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.

4 participants