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

CLI: New dotenv output format #4174

Open
arturcic opened this issue Aug 21, 2024 Discussed in #4173 · 1 comment
Open

CLI: New dotenv output format #4174

arturcic opened this issue Aug 21, 2024 Discussed in #4173 · 1 comment
Milestone

Comments

@arturcic
Copy link
Member

Discussed in #4173

Originally posted by cimnine August 21, 2024
I would appreciate it if the GitVersion CLI could output all the variables in dotenv format:

$ dotnet gitversion -output dotenv
AssemblySemFileVer=1.0.1.0
AssemblySemVer=1.0.1.0
BranchName=main
BuildMetaData=
CommitDate=2024-08-21
CommitsSinceVersionSource=0
…

This would allow more simplified CI/CD jobs with the two most important CI systems, GitLab CI and GitHub Actions. Both allow to pass environment variables to other jobs by writing them to a specific file (as documented for GitLab and GitHub). The first step of the pipeline would calculate the GitVersion-variables and export them, and all subsequent jobs could use those variables.

One important thing to consider is what to do with null values. In the example above, BuildMetaData is null. If it's in the output, the environment variable will be defined as empty. But most probably, all GitVersion-variables that are null should not be printed at all in dotenv mode.

@arturcic arturcic added this to the 6.x milestone Aug 21, 2024
@rose-a
Copy link
Contributor

rose-a commented Sep 3, 2024

I suggest they should be prefixed with GitVersion_ (i.e. GitVersion_AssemblySemVer) to avoid name collisions.

I'd strongly recommend writing out null values because then they would explicitly override/reset previously set values. Not doing that could lead to potentially weird results for people using those variables (like PreReleaseLabel for instance).

That would basically be the exact output of the GitLab build server integration (albeit to the console)...

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

No branches or pull requests

2 participants