Skip to content

Question: How to use Continous Deployment with GitVersionTask? #417

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

Closed
MeirionHughes opened this issue Apr 8, 2015 · 23 comments
Closed

Comments

@MeirionHughes
Copy link
Contributor

My workflow is to automatically deploy anything from the master or release-* (as pre-release) to nuget (teamcity). I noticed as I commit changes to a release branch that the -beta1 isn't incrementing.

I think I've read that I need to switch to Continuous Deployment mode, but I couldn't see how to do this if I'm just using GitVersionTask off nuget.

@JakeGinnivan
Copy link
Contributor

The GitVersionTask will still respect the GitVersionConfig.yaml file if your project root. Just create the config file using the information at https://github.com/ParticularLabs/GitVersion#branch-configuration

Feel free to submit a pull request or update our docs to help others find this info :)

@MeirionHughes
Copy link
Contributor Author

hmm can't seem to bring up the default config. GitVersion showConfig and GitVersion /showConfig both result in Failed to prepare or find the .git directory in path '/showConfig'

@gep13
Copy link
Member

gep13 commented Apr 8, 2015

Can you grab a screenshot of the command window where you are running the command? Also, what is the complete command that you are running? Are you using the targetPath parameter?

The error that you are getting suggests that GitVersion has been unable to locate the .git folder which git manages behind the scenes for you. This can happen when you have specified the wrong targetPath parameter, or you are running GitVersion on the command line in the incorrect directory.

@MeirionHughes
Copy link
Contributor Author

Nothing special, installed via Chocolaty - although I had to skip some step because its not working properly. Ran this is admin cmd...

D:\Code\RobGeoLtd\Data.Components>GitVersion
{
"Major":0,
"Minor":4,
"Patch":0,
"PreReleaseTag":"beta.1",
"PreReleaseTagWithDash":"-beta.1",
"BuildMetaData":2,
"FullBuildMetaData":"2.Branch.release/release-0.4.Sha.ec8690f9dc6b5ac715d0f40669cd5ef33febfc54",
"MajorMinorPatch":"0.4.0",
"SemVer":"0.4.0-beta.1",
"LegacySemVer":"0.4.0-beta1",
"LegacySemVerPadded":"0.4.0-beta0001",
"AssemblySemVer":"0.4.0.0",
"AssemblyFileSemVer":"0.4.0.0",
"FullSemVer":"0.4.0-beta.1+2",
"InformationalVersion":"0.4.0-beta.1+2.Branch.release/release-0.4.Sha.ec8690f9dc6b5ac715d0f40669cd5ef33febfc54",
"ClassicVersion":"0.4.0.2",
"ClassicVersionWithTag":"0.4.0.2-beta.1",
"BranchName":"release/release-0.4",
"Sha":"ec8690f9dc6b5ac715d0f40669cd5ef33febfc54",
"NuGetVersionV2":"0.4.0-beta0001",
"NuGetVersion":"0.4.0-beta0001"
}

D:\Code\RobGeoLtd\Data.Components>GitVersion showConfig
Failed to prepare or find the .git directory in path 'showConfig'

D:\Code\RobGeoLtd\Data.Components>GitVersion /showConfig
Failed to prepare or find the .git directory in path '/showConfig'

@gep13
Copy link
Member

gep13 commented Apr 8, 2015

ah, hold on....

What version of GitVersion have you got installed? Are you using the latest pre-release version, i.e. 3.0.0-beta2?

To install this from chocolatey, you will need to do:

choco install gitversion.portable -pre -y

I suspect you might have an earlier version, that isn't recognising the /showconfig command. But that is just a guess at this point.

@MeirionHughes
Copy link
Contributor Author

with -y it fails, so with -n to stop the script it runs... but its still installing 2.0.1

choco install gitversion.portable -pre -n --force
Chocolatey v0.9.9.4
Installing the following packages:
gitversion.portable
By installing you accept licenses for the packages.
GitVersion.Portable v2.0.1 (forced)
ShimGen has successfully created a shim for GitVersion.exe
gitversion.portable has been installed successfully.
Chocolatey installed 1/1 package(s). 0 package(s) failed.
See the log for details.

@gep13
Copy link
Member

gep13 commented Apr 8, 2015

Hmm, that is very strange, hold on... let me try something...

@gep13
Copy link
Member

gep13 commented Apr 8, 2015

Hmm, I have just tried this:

C:\github\Organisations\chocolatey> choco install gitversion.portable -pre -y -n
Chocolatey v0.9.9.4
Installing the following packages:
gitversion.portable
By installing you accept licenses for the packages.

GitVersion.Portable v3.0.0-beta0002
 ShimGen has successfully created a shim for GitVersion.exe
 gitversion.portable has been installed successfully.

Chocolatey installed 1/1 package(s). 0 package(s) failed.
 See the log for details.

And it works as expected. Can you try without the --force. You shouldn't need that. The need for -n is a known issue which I raised an issue about this morning:

chocolatey/choco#230

The problem being that GitVersion is/was actually using an undocumented method that was never part of the Public API of Chocolatey. We have taken the decision to add this method into the public API, but the current implementation doesn't work correctly yet, we are working on it though.

@MeirionHughes
Copy link
Contributor Author

Without --force its the same. (just doesn't install - already installed). I'm on windows 7 btw. Are versions limited to OS at all?

Admittedly, I'm new to this. I installed Chocolaty in an admin cmd prompt. It seemed to install happily.

Okay, I can attempt to install with a specific version it seems:
choco install gitversion.portable -version 3.0.0-beta0001 -pre

but its complaining with and without the script now. :/

@gep13
Copy link
Member

gep13 commented Apr 8, 2015

No, the OS shouldn't make any difference. I am running on Windows 7 as well.

Ok, do this for me...

  • Go to C:\ProgramData\chocolatey\lib
  • Find any folders with GitVersion.Portable, and delete them
  • Go to C:\ProgramData\chocolatey\lib-bad
  • Find any folders with GitVersion.Portable, and delete them
  • Go to C:\ProgramData\chocolatey\lib-bkp
  • Find any folders with GitVersion.Portable, and delete them
  • Go to C:\ProgramData\chocolatey.chocolatey
  • Find any folders with GitVersion.Portable, and delete them
  • Go to C:\Users\All Users\chocolatey\bin
  • If there are any files starting with Gitversion, delete them
  • If there are any files starting with gfv, delete them

After all that, close you console/powershell window and run the following command:

choco install gitversion.portable -pre -y -n

And hopefully that will get you back to a known state.

@MeirionHughes
Copy link
Contributor Author

Phew... finally, choco install gitversion.portable -version 3.0.0-beta0002 -pre with skip did the trick. Got the config. :)

@gep13
Copy link
Member

gep13 commented Apr 8, 2015

Woot! 👍

@MeirionHughes
Copy link
Contributor Author

Okay cool this all seems to be working now. Commits to an active release-branch is upping the beta version number. I think I may have had some issues by messing with tags manually (moving them up). After closing and opening a new release via SourceTree, it all seems to be working well. Thank you. :)

@MeirionHughes
Copy link
Contributor Author

Sorry, spoke too soon. I have some odd behavior with the BuildMetaData number. If I've just been working locally the beta number moves up with each commit as I'm expecting:

Tree

"Major":0,
"Minor":6,
"Patch":0,
"PreReleaseTag":"beta.4",
"PreReleaseTagWithDash":"-beta.4",
"BuildMetaData":4,
"FullBuildMetaData":"4.Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"MajorMinorPatch":"0.6.0",
"SemVer":"0.6.0-beta.4",
"LegacySemVer":"0.6.0-beta4",
"LegacySemVerPadded":"0.6.0-beta0004",
"AssemblySemVer":"0.6.0.0",
"FullSemVer":"0.6.0-beta.4",
"InformationalVersion":"0.6.0-beta.4+Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"BranchName":"release/release-0.6",
"Sha":"061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"NuGetVersionV2":"0.6.0-beta0004",
"NuGetVersion":"0.6.0-beta0004"

However, if I now push the release branch onto the remote server and run GitVersion I get this:

Tree2

"Major":0,
"Minor":6,
"Patch":0,
"PreReleaseTag":"beta.1",
"PreReleaseTagWithDash":"-beta.1",
"BuildMetaData":1,
"FullBuildMetaData":"1.Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"MajorMinorPatch":"0.6.0",
"SemVer":"0.6.0-beta.1",
"LegacySemVer":"0.6.0-beta1",
"LegacySemVerPadded":"0.6.0-beta0001",
"AssemblySemVer":"0.6.0.0",
"FullSemVer":"0.6.0-beta.1",
"InformationalVersion":"0.6.0-beta.1+Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"BranchName":"release/release-0.6",
"Sha":"061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"NuGetVersionV2":"0.6.0-beta0001",
"NuGetVersion":"0.6.0-beta0001"

Have I missed something?

I've checked back on my build log and I think GitVersion 2 was correctly incrementing the meta number off the remote branch.

@MeirionHughes MeirionHughes reopened this Apr 8, 2015
@gep13
Copy link
Member

gep13 commented Apr 8, 2015

Can you confirm that the same version of GitVersion is being used both locally, and on the server?

Sent from my Windows Phone


From: Meirion Hughesmailto:[email protected]
Sent: ‎08/‎04/‎2015 15:11
To: ParticularLabs/GitVersionmailto:[email protected]
Cc: Gary Ewan Parkmailto:[email protected]
Subject: Re: [GitVersion] Question: How to use Continous Deployment with GitVersionTask? (#417)

Sorry, spoke too soon. I have some odd behavior with the BuildMetaData number. If I've just been working locally the beta number moves up with each commit as I'm expecting:

Tree

"Major":0,
"Minor":6,
"Patch":0,
"PreReleaseTag":"beta.4",
"PreReleaseTagWithDash":"-beta.4",
"BuildMetaData":4,
"FullBuildMetaData":"4.Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"MajorMinorPatch":"0.6.0",
"SemVer":"0.6.0-beta.4",
"LegacySemVer":"0.6.0-beta4",
"LegacySemVerPadded":"0.6.0-beta0004",
"AssemblySemVer":"0.6.0.0",
"FullSemVer":"0.6.0-beta.4",
"InformationalVersion":"0.6.0-beta.4+Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"BranchName":"release/release-0.6",
"Sha":"061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"NuGetVersionV2":"0.6.0-beta0004",
"NuGetVersion":"0.6.0-beta0004"

However, if I now push the release branch onto the remote server and run GitVersion I get this:

"Major":0,
"Minor":6,
"Patch":0,
"PreReleaseTag":"beta.1",
"PreReleaseTagWithDash":"-beta.1",
"BuildMetaData":1,
"FullBuildMetaData":"1.Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"MajorMinorPatch":"0.6.0",
"SemVer":"0.6.0-beta.1",
"LegacySemVer":"0.6.0-beta1",
"LegacySemVerPadded":"0.6.0-beta0001",
"AssemblySemVer":"0.6.0.0",
"FullSemVer":"0.6.0-beta.1",
"InformationalVersion":"0.6.0-beta.1+Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"BranchName":"release/release-0.6",
"Sha":"061020d8e0a36ccc5bed1885a4bddbcc6cd15319",
"NuGetVersionV2":"0.6.0-beta0001",
"NuGetVersion":"0.6.0-beta0001"


Reply to this email directly or view it on GitHub:
#417 (comment)

@MeirionHughes
Copy link
Contributor Author

I was running GitVersion locally (same cmd prompt) both times. All I did was to have git push the branch onto the remote origin. I then ran GitVersion again locally and the beta number changed down from 4 to 1.

What I don't know is whether I'm using this wrong, or its a bug. My understanding was that if I add commits to a release branch, its beta number will increase.

I'll freely admit I'm new to all this. :D

@JakeGinnivan
Copy link
Contributor

Can you run gitversion /l console

It will log out some information which might help diagnose

@MeirionHughes
Copy link
Contributor Author

Before Pushing to Origin:

061020d (release/release-0.6)
bc7924f
57e8ffc
e87307f
7d66f6c (origin/develop)(develop)

Output:

"BuildMetaData":4,
"FullBuildMetaData":"4.Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",

Log:

Working directory: D:\Code\RobGeoLtd\Data
No specific commit specified or found, falling back to latest commit on specified branch
Running against branch: release/release-0.6
Base Versions:
Fallback base version: 0.1.0 from commit 8854f36d33709570d2b4c665655b9db77c4dc885
Git tag 'release-0.4': 0.4.0 from commit 254f4b8d38e894553bd1d07d53d2327eed608b4c
Git tag 'release-0.4': 0.4.0 from commit 254f4b8d38e894553bd1d07d53d2327eed608b4c
Version in branch name: 0.6.0 from commit 7d66f6c129405aa142bbe04c7bc414ca5fdc98c3
Base version used: Version in branch name: 0.6.0 from commit 7d66f6c129405aa142bbe04c7bc414ca5fdc98c3
Skipping version increment

After push to Origin

061020d (origin/release/release-0.6)(release/release-0.6)
bc7924f
57e8ffc
e87307f
7d66f6c (origin/develop)(develop)

Output:

"BuildMetaData":1,
"FullBuildMetaData":"1.Branch.release/release-0.6.Sha.061020d8e0a36ccc5bed1885a4bddbcc6cd15319",

Log

Working directory: D:\Code\RobGeoLtd\Data
No specific commit specified or found, falling back to latest commit on specified branch
Running against branch: release/release-0.6
Base Versions:
Fallback base version: 0.1.0 from commit 8854f36d33709570d2b4c665655b9db77c4dc885
Git tag 'release-0.4': 0.4.0 from commit 254f4b8d38e894553bd1d07d53d2327eed608b4c
Git tag 'release-0.4': 0.4.0 from commit 254f4b8d38e894553bd1d07d53d2327eed608b4c
Version in branch name: 0.6.0 from commit bc7924f517fe7fc41d4371b9f000963adb54a6c4
Base version used: Version in branch name: 0.6.0 from commit bc7924f517fe7fc41d4371b9f000963adb54a6c4
Skipping version increment

They look identical except for base version commit

@MeirionHughes
Copy link
Contributor Author

So is this a bug or working as intended? If its a bug I'll have a go fixing it. But its not clear.

@JakeGinnivan
Copy link
Contributor

I think it's a bug... It doesn't look right

@MeirionHughes
Copy link
Contributor Author

I've tried to test for it, but I can't seem to get pushing to a remote right :(

LibGit2Sharp complains: "Local push doesn't (yet) support pushing to non-bare repos."

https://github.com/MeirionHughes/GitVersion/commit/d69c1e8562e78f849877567f1c2b0cfe3062c535

@MeirionHughes
Copy link
Contributor Author

I think I've found the problem. In Extensions-> FindCommitBranchWasBranchedFrom

c.GetBranchesContainingCommit(repository, onlyTrackedBranches).ToList()

...includes the remote branch as well as the local. So the count is higher than if the remote branch was behind or not on remote.

@MeirionHughes
Copy link
Contributor Author

Test and Fix: #442

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.

3 participants