Skip to content

Conversation

bendoyon
Copy link

@bendoyon bendoyon commented May 13, 2020

Fix an issue where GITVERSION_REMOTE_PASSWORD would overwrite the Username options intead of setting the Password option.

Also make sure authentication is set even if no other command line arguments are present.

Description

Changed the one-liner where the assignation happens in ArgumentParser.cs. Pretty self-evident change. Relevant unit tests have been added.

While making this change, I realized that my tests failed when no other command line arguments were passed. I made sure to add authentication even in the case where no other command line arguments exist, and added relevant unit tests.

Related Issue

Fixes #2276

Motivation and Context

I need this to get GitVersion working in a GitLab CI build that needs authentication because it builds with Docker.

How Has This Been Tested?

I have added 4 relevant unit tests.

Checklist:

  • My code follows the code style of this project.
  • [n/a] My change requires a change to the documentation.
  • [n/a] I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…rname options intead of setting the Password option.

Also make sure authentication is set even if no other command line arguments are present.
Copy link
Member

@arturcic arturcic left a comment

Choose a reason for hiding this comment

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

Good catch!

@bendoyon
Copy link
Author

@arturcic Thanks! Still some authentication on my end, I'm getting a "Could not find a 'develop' or 'master' branch, neither locally nor remotely." when in a Docker build running on GitLab CI.

This didn't end up fixing it, but we're getting closer maybe...

@arturcic
Copy link
Member

You should pass the GitLab env vars to the docker run from the GitLab pipeline

@arturcic
Copy link
Member

@arturcic
Copy link
Member

@bendoyon
Copy link
Author

@arturcic Yikes, getting a NullReference now:

/root/.nuget/packages/gitversiontask/5.4.0-pullrequest2277-50/build/GitVersionTask.targets(10,9): error : NullReferenceException: Object reference not set to an instance of an object. [/src/Services.Common/Services.Common.csproj]
/root/.nuget/packages/gitversiontask/5.4.0-pullrequest2277-50/build/GitVersionTask.targets(10,9): error : at GitVersion.Extensions.RepositoryExtensions.CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(IRepository repo, ILog log, String remoteName) in D:\a\GitVersion\GitVersion\src\GitVersionCore\Extensions\RepositoryExtensions.cs:line 177 [/src/Services.Common/Services.Common.csproj]

Which seems to be this line:
if (localRef.ResolveToDirectReference().TargetIdentifier == remotedirectReference.TargetIdentifier)

@arturcic
Copy link
Member

You are using GitversionTask it Gitversion.Tool? As what you fixed is for the tool, not the task

@bendoyon
Copy link
Author

bendoyon commented May 13, 2020

Is there any way of passing parameters to the MsBuild task? I could use the dynamic repository feature to make sure it has access to everything it needs, instead of copying the .git repository into the Docker image.

Using the GitVersionTask, I was looking through the code to see if I could trace my change into the task but it doesn't look like it. Looks like the documentation is not accurate, then.

https://gitversion.readthedocs.io/en/latest/input/docs/usage/msbuild-task/

At the very bottom of the page.

@bendoyon
Copy link
Author

@arturcic I figured the Task is an elegant way to make it work both locally, and from the CI, sort of seamlessly. Is there any way to achieve the same thing with the EXE?

For example, I have a test validating that my ASP.NET Core endpoint can return the Git version, when I run the tests on my local machine, when the tests are run in the CI, and when the application is deployed.

Is there a way to have a similar sort of workflow with the EXE?

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.

[Bug] GITVERSION_REMOTE_PASSWORD environment variable overwrites the Username field instead of setting the password
2 participants