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

gitVersion 4.0.0 in new image fails on pull request builds #2740

Open
antyrama opened this issue Nov 13, 2018 · 4 comments
Open

gitVersion 4.0.0 in new image fails on pull request builds #2740

antyrama opened this issue Nov 13, 2018 · 4 comments
Labels

Comments

@antyrama
Copy link

antyrama commented Nov 13, 2018

Looks like after recent Visual Studio 2017 image update we are experiencing issues with gitVersion tool in version 4.0.0 (unable to use earlier version due to above update). It works fine when building from branches but fails on pull request builds.

Steps to reproduce:

  1. Make sure appveyor.yml file contains below actions:
version: "{build}"

install:  
  - choco install gitversion.portable --version 4.0.0 -y
 
build_script:
  - ps: gitversion $env:APPVEYOR_BUILD_FOLDER /l console /output buildserver /nofetch /b $env:APPVEYOR_REPO_BRANCH
  
# whatever else you want to do
  1. Add gitVersion.yml configuration file:
mode: ContinuousDeployment
tag-prefix: '[vV]'
continuous-delivery-fallback-tag: ''
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
legacy-semver-padding: 5
build-metadata-padding: 5
commits-since-version-source-padding: 5
commit-message-incrementing: Enabled
branches:
  master:
    regex: master
    mode: ContinuousDeployment
    tag: ''
    increment: None
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
  release:
    regex: releases?[/-]
    mode: ContinuousDeployment
    tag: ''
    increment: None
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
  feature:
    regex: features?[/-]
    mode: ContinuousDeployment
    tag: alpha
    increment: Inherit
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
  pull-request:
    regex: (pull|pull\-requests|pr)[/-]
    mode: ContinuousDeployment
    tag: PullRequest
    increment: Inherit
    prevent-increment-of-merged-branch-version: false
    tag-number-pattern: '[/-](?<number>\d+)[-/]'
    track-merge-target: false
  hotfix:
    regex: hotfix(es)?[/-]
    mode: ContinuousDeployment
    tag: ''
    increment: Patch
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
  bugfix:
    regex: bugfix(es)?[/-]
    mode: ContinuousDeployment
    tag: alpha
    increment: Patch
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    source-branches: ['develop']
  develop:
    regex: dev(elop)?(ment)?$
    mode: ContinuousDeployment
    tag: beta
    increment: Minor
    prevent-increment-of-merged-branch-version: false
    track-merge-target: true
  1. Push changes to develop
  2. Branch out from develop to feature branch
  3. Make a change and push changes
  4. Go to gitHub and create pull request of your feature branch back to develop

Current result

gitVersion tool fails and prints below message

gitversion $env:APPVEYOR_BUILD_FOLDER /l console /output buildserver /updateAssemblyInfo /nofetch /b $env:APPVEYOR_REPO_BRANCH
INFO [11/13/18 11:08:41:31] Working directory: C:\projects.......................
INFO [11/13/18 11:08:41:33] IsDynamicGitRepository: False
INFO [11/13/18 11:08:41:47] Returning Project Root from DotGitDirectory: C:\projects..................git - C:\projects......................
INFO [11/13/18 11:08:41:48] Running on Windows.
INFO [11/13/18 11:08:41:48] Applicable build agent found: 'AppVeyor'.
INFO [11/13/18 11:08:41:49] Branch from build environment: develop
INFO [11/13/18 11:08:41:49] Begin: Normalizing git directory for branch 'develop'
INFO [11/13/18 11:08:41:59] One remote found (origin -> '[email protected]:........./..............git').
INFO [11/13/18 11:08:41:59] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
INFO [11/13/18 11:08:41:60] Updating local branch refs/heads/develop to match ref develop
INFO [11/13/18 11:08:41:64] Creating local branch from remote tracking 'refs/remotes/origin/features/BEN-....'.
INFO [11/13/18 11:08:41:66] Creating local branch from remote tracking 'refs/remotes/origin/features/BEN-....'.
INFO [11/13/18 11:08:41:67] Creating local branch from remote tracking 'refs/remotes/origin/features/BEN-....'.
INFO [11/13/18 11:08:41:69] Creating local branch from remote tracking 'refs/remotes/origin/features/gitVersion-test'.
INFO [11/13/18 11:08:41:70] Creating local branch from remote tracking 'refs/remotes/origin/master'.
INFO [11/13/18 11:08:41:70] HEAD points at branch 'refs/heads/develop'.
INFO [11/13/18 11:08:41:71] End: Normalizing git directory for branch 'develop' (Took: 220.01ms)
ERROR [11/13/18 11:08:41:71] An unexpected error occurred:
GitTools.Git.BugException: GitTools.Core has a bug, your HEAD has moved after repo normalisation.
To disable this error set an environmental variable called IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1
Please run git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=* -n 100 and submit it along with your build log (with personal info removed) in a new issue at https://github.com/GitTools/GitTools.Core
at GitTools.Git.GitRepositoryHelper.NormalizeGitDirectory(String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch)
at GitVersion.GitPreparer.Initialise(Boolean normaliseGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes)
at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache)
at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()

INFO [11/13/18 11:08:41:72]
INFO [11/13/18 11:08:41:72] Attempting to show the current git graph (please include in issue):
INFO [11/13/18 11:08:41:72] Showing max of 100 commits
INFO [11/13/18 11:08:41:77] * be07c17 81 seconds ago (origin/features/gitVersion-test, features/gitVersion-test)
...
...
...

Steps taken to fix

Step suggested in an error message didn't help.

Desired result

gitVersion tool works as expected also for pull request builds

@OwenMcDonnell
Copy link

Apparently, we were a little hasty in upgrading to gitversion 4 which has some bugs. If it is not stabilized by the time we roll out the next platform update, we will have to roll it back.
In the meantime, you can add this script to install: section of your appveyor.yml or install scripts if you use UI.

  - ps: |
  
      Write-Host "Installing GitVersion 3.6.5..." -ForegroundColor Cyan
      $gvPath = "$env:SYSTEMDRIVE\Tools\GitVersion"
      if(Test-Path $gvPath) {
          del $gvPath -Recurse -Force
      }
      $tempPath = "$env:USERPROFILE\GitVersion"
      nuget install gitversion.commandline -version 3.6.5 -excludeversion -outputdirectory $tempPath
      [IO.Directory]::Move("$tempPath\gitversion.commandline\tools", $gvPath)
      del $tempPath -Recurse -Force
      Add-Path $gvPath
      Write-Host "GitVersion 3.6.5 installed" -ForegroundColor Green

@antyrama
Copy link
Author

Well, yeah, this is what we know already :) the real outcome of this will be dozens of hours spent on updating each code repo, only me have checked out about 36 of them and there is another 8 members of a team in project, if you multiply it let say by 5 branches each - I'm terrified...

Actually it doesn't matter if we add the above script or we use previous image, it still will require to touch each branch.

Is there a way to take it back to previous image only for our organisation? It would save us tremendous amount of time.

Anyway, thanks for the workaround script, I'll test it and let you know about the result.

@antyrama
Copy link
Author

Script works fine, I had to also get back to previous version of gitVersion.yml.
Hope to hear more soon how to solve it without touching YAML files.

@IlyaFinkelshteyn
Copy link
Contributor

@antyrama:

If you add APPVEYOR_BUILD_WORKER_IMAGE with the value of Previous Visual Studio 2017 or Previous Visual Studio 2015 into Environment tab in UI, it will have precedence over image set up in YAML. I think that it would be easier to walk over UI setting than edit all that YAMLs.

Or we can write a script which will update it with API, you will be needed just pass account name, API token, project slug and desired image to this script, and run the script against each project slug with desired image.

Let us know what would work for you.

mrstebo added a commit to mrstebo/serilog-enrichers-correlation-id that referenced this issue Jan 2, 2019
@FeodorFitsner FeodorFitsner removed this from the next-images-update milestone Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants