0
votes

We are using jenkins pipeline (blue ocean) to build our project.

How can we get gitversion working in jenkinsfile?

When trying gitversion.exe /output buildserver: C:\jenkins\workspace\mastere809bb9e>buildtools\GitVersion\tools\GitVersion.exe /output buildserver

INFO [01/18/18 8:17:27:73] Working directory: C:\jenkins\workspace\mastere809bb9e

INFO [01/18/18 8:17:27:75] Applicable build agent found: 'Jenkins'.

INFO [01/18/18 8:17:27:75] Branch from build environment:

ERROR [01/18/18 8:17:27:82] An unexpected error occurred:

System.ArgumentNullException: Der Wert darf nicht NULL sein.

Parametername: path

bei LibGit2Sharp.Core.Ensure.ArgumentNotNull(Object argumentValue, String argumentName)

bei LibGit2Sharp.Core.Ensure.ArgumentNotNullOrEmptyString(String argumentValue, String argumentName)

bei LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options)

bei GitVersion.GitHelper.NormalizeGitDirectory(String gitDirectory, Authentication authentication, Boolean noFetch, String currentBranch)

bei GitVersion.GitPreparer.Initialise(Boolean normaliseGitDirectory, String currentBranch)

bei GitVersion.ExecuteCore.ExecuteGitVersion(IFileSystem fileSystem, String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId)

bei GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)

bei GitVersion.Program.VerifyArgumentsAndRun()

INFO [01/18/18 8:17:27:82]

INFO [01/18/18 8:17:27:82] Here is the current git graph (please include in issue):

INFO [01/18/18 8:17:27:82] Showing max of 100 commits

INFO [01/18/18 8:17:27:90] ERROR: fatal: Not a git repository (or any of the parent directories): .git

1
Hi, I already tried "gitversion /output buildserver" but this is not working:C:\jenkins\workspace\mastere809bb9e> INFO [01/18/18 7:25:42:92] ERROR: fatal: Not a git repository (or any of the parent directories): .gitMatthias Kammerlohr

1 Answers

0
votes

GitVersion requires information from the Git repository in order for it to calculate a SemVer version for your code.

To help resolve your issue, in your Jenkins pipeline I would add a step to git clone -b <branch> <remote-repo> and use this as your sources directory. (I don't use Jenkins, but I would imagine they already have a task/step/whatever that can do this.) Then you can run GitVersion and have it calculate the version of your code (making sure to follow the Jenkins Setup instructions at GitVersion).