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

Add assembly-file-versioning-format with support for environment variables #1385

Merged

Conversation

ruhullahshah
Copy link
Contributor

Fix for issue #1366

Implementation methodology same as suggested by @jbaehr in #1157

@jbaehr jbaehr mentioned this pull request Mar 14, 2018
@jbaehr
Copy link
Contributor

jbaehr commented Mar 16, 2018

Thanks a lot for your work. I gave it a try and it works like a charm (just remember to call GitVersion.exe with -nocache when playing around ;-) ).

I would love a comment from the maintainers whether this approach has chances to get merged. @asbjornu, you already gave thumbs up on my comment in #1157... Please tell us if you request further changes to the implementation, format string syntax, or the like.

@ruhullahshah
Copy link
Contributor Author

@jbaehr You are welcome and thanks for testing out the changes :)

Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

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

I think this looks really promising. I just have a few comments, so please address or debate them before we move forward. Thanks for doing this!

src/GitVersionCore.Tests/StringFormatWithExtensionTests.cs Outdated Show resolved Hide resolved
src/GitVersionCore/Configuration/Config.cs Outdated Show resolved Hide resolved
src/GitVersionCore/StringFormatWith.cs Outdated Show resolved Hide resolved
@ruhullahshah
Copy link
Contributor Author

@asbjornu You are welcome. I have addressed some of your review comments and provided my opinion on others. In my opinion, we have the functionality in place that addresses the theme of this issue.

Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

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

I think this looks good now, minus one question. Thanks!

src/GitVersionCore.Tests/StringFormatWithExtensionTests.cs Outdated Show resolved Hide resolved
@ruhullahshah
Copy link
Contributor Author

You are welcome. I have included the changes for the null propagation operator readability and updated some test cases.

Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

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

Just a few new questions, otherwise this looks good!

src/GitVersionCore/OutputVariables/VariableProvider.cs Outdated Show resolved Hide resolved
src/GitVersionCore/StringFormatWith.cs Outdated Show resolved Hide resolved
src/GitVersionCore/StringFormatWith.cs Outdated Show resolved Hide resolved
@ruhullahshah
Copy link
Contributor Author

ruhullahshah commented Mar 24, 2018

@asbjornu I would like to address all the changes you request in one go. This is getting repetitive. The review before this should have had these comments because these changes have been there before the last commit. I will give you some time to make up your mind about the PR as a whole and once you have reviewed all the code let me know, i will address your comments.

@asbjornu
Copy link
Member

@ruhullahshah: Sorry about that. I was sure the latest review was for new code. I should of course have reviewed that in the first go, but if I remember correctly, I had limited time when I did the first review so it wasn't as thorough as I would have liked.

@asbjornu
Copy link
Member

Excellent. Thanks for this!

@asbjornu asbjornu merged commit dbd80e1 into GitTools:master Mar 26, 2018
@ruhullahshah
Copy link
Contributor Author

You are welcome :)

@ruhullahshah ruhullahshah deleted the feature/env_var_support_in_conf_file branch March 26, 2018 22:38
@asbjornu asbjornu changed the title Fix issue Montonically increasing AssemblyFileVersion to satisfy the … Add assembly-file-versioning-format with support for environment variables Sep 6, 2019
@vishalvatsal
Copy link

vishalvatsal commented Jun 25, 2020

Hi Team,
@asbjornu , @ruhullahshah
I have a need to use build number in the assembly version for my TeamCity build.

Following is my gitversion config

next-version: 1.0.0
assembly-versioning-scheme: MajorMinorPatch
assembly-versioning-format: '{Major}.{Minor}.{Patch}.{env:BUILD_COUNTER??0}'
assembly-file-versioning-scheme: MajorMinorPatch
continuous-delivery-fallback-tag: ''
mode: ContinuousDeployment
branches:
    release:
        tag: ''        
    develop:
        tag: 'dev'
    master:
        tag: 'master'
ignore:
  sha: []
merge-message-formats: {}

In Team City project I have an environment variable

Name: env.BUILD_COUNTER
Value: %build.counter%

After the build this is what I get
GitVersion.AssemblySemVer = 1.0.0.{env:BUILD_COUNTER??0}

Can you please let me know what I am doing wrong here? Or what do I need to do to make sure env:BUILD_COUNTER gets substituted with the correct value?

Thank you

@jbaehr
Copy link
Contributor

jbaehr commented Jun 25, 2020

@vishalvatsal The implementation in this PR explicitly requires spaces around the ?? in order to treat it as a fallback-separator. Your config sample seem to omit those spaces.

Note however, that the currently latest GitVersion release features an enhanced implementation, that further allows fallback strings for regular GitVersion variables, too, and also allows for quoted fallback strings containing special characters. cf. #2179

@vishalvatsal
Copy link

Thanks a ton @jbaehr.

It works now.

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