Skip to content

Dockerfile giving null reference exception? #1441

@yamikuronue

Description

@yamikuronue

I am attempting to capture the correct image number so it can be baked into Packer when building my AMIs. I am using the following partial build.sh to capture that information in an environment variable so I can pass it along to Packer:

IMAGE_VERSION=$(docker run --rm -u $(id -u):$(id -g) -v $(pwd):/repo gittools/gitversion:v4.0.0-beta.12 /showvariable SemVer)


echo "Building images version $IMAGE_VERSION"

I am running this on a linux agent in teamcity (the current teamcity plugin requires Powershell apparently). I am building on a branch in a repo, it's a fairly new repo so there's nothing weird going on. I am getting the following output:

[16:35:39][Step 1/1] Building images version INFO [07/05/18 20:35:37:21] Working directory: /repo
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:22] IsDynamicGitRepository: False
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:25] Returning Project Root from DotGitDirectory: /repo/.git - /repo
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:25] Running on Mono.
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:26] IsDynamicGitRepository: False
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:26] Returning Project Root from DotGitDirectory: /repo/.git - /repo
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:26] Project root is: /repo
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:26] DotGit directory is: /repo/.git
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:27] IsDynamicGitRepository: False
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:27] Returning Project Root from DotGitDirectory: /repo/.git - /repo
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:30] Begin: Loading version variables from disk cache
[16:35:39][Step 1/1]   INFO [07/05/18 20:35:37:31] Cache file /repo/.git/gitversion_cache/A2990A7006B056135D53E257F3260AEE6BE8A13C.yml not found.
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:31] End: Loading version variables from disk cache (Took: 1.44ms)
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:31] IsDynamicGitRepository: False
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:31] Returning Project Root from DotGitDirectory: /repo/.git - /repo
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:44] Using latest commit on specified branch
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:45] Begin: Attempting to inherit branch configuration from parent branch
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:45] End: Attempting to inherit branch configuration from parent branch (Took: 0.22ms)
[16:35:39][Step 1/1] ERROR [07/05/18 20:35:37:45] An unexpected error occurred:
[16:35:39][Step 1/1] System.NullReferenceException: Object reference not set to an instance of an object
[16:35:39][Step 1/1]   at GitVersion.BranchConfigurationCalculator.InheritBranchConfiguration (GitVersion.GitVersionContext context, LibGit2Sharp.Branch targetBranch, GitVersion.BranchConfig branchConfiguration, System.Collections.Generic.IList`1[T] excludedInheritBranches) [0x00035] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.BranchConfigurationCalculator.GetBranchConfiguration (GitVersion.GitVersionContext context, LibGit2Sharp.Branch targetBranch, System.Collections.Generic.IList`1[T] excludedInheritBranches) [0x000f0] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.GitVersionContext.CalculateEffectiveConfiguration () [0x00007] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.GitVersionContext..ctor (LibGit2Sharp.IRepository repository, LibGit2Sharp.Branch currentBranch, GitVersion.Config configuration, System.Boolean onlyEvaluateTrackedBranches, System.String commitId) [0x00121] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.GitVersionContext..ctor (LibGit2Sharp.IRepository repository, GitVersion.Config configuration, System.Boolean isForTrackingBranchOnly, System.String commitId) [0x00008] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.ExecuteCore+<>c__DisplayClass6_0.<ExecuteInternal>b__0 (LibGit2Sharp.IRepository repo) [0x00000] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.GitPreparer.WithRepository[TResult] (System.Func`2[T,TResult] action) [0x0000c] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.ExecuteCore.ExecuteInternal (System.String targetBranch, System.String commitId, GitVersion.GitPreparer gitPreparer, GitVersion.IBuildServer buildServer, GitVersion.Config overrideConfig) [0x0002d] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.ExecuteCore.ExecuteGitVersion (System.String targetUrl, System.String dynamicRepositoryLocation, GitVersion.Authentication authentication, System.String targetBranch, System.Boolean noFetch, System.String workingDirectory, System.String commitId, GitVersion.Config overrideConfig, System.Boolean noCache) [0x000df] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.SpecifiedArgumentRunner.Run (GitVersion.Arguments arguments, GitVersion.Helpers.IFileSystem fileSystem) [0x0007c] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1]   at GitVersion.Program.VerifyArgumentsAndRun () [0x00182] in <248b18560e0a4c7a85ffc14b47d49ab1>:0 
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:45] 
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:45] Attempting to show the current git graph (please include in issue): 
[16:35:39][Step 1/1] INFO [07/05/18 20:35:37:45] Showing max of 100 commits
[16:35:39][Step 1/1] INFO [07/05/18 20:35:38:39] ERROR: error: object directory /opt/teamcity-buildagent/system/git/git-B2CDEA8F.git/objects does not exist; check .git/objects/info/alternates.
[16:35:39][Step 1/1] ERROR: error: refs/heads/feature/cicd does not point to a valid object!
[16:35:39][Step 1/1] ERROR: error: refs/heads/master does not point to a valid object!
[16:35:39][Step 1/1] ERROR: error: refs/remotes/origin/feature/cicd does not point to a valid object!
[16:35:39][Step 1/1] ERROR: error: refs/remotes/origin/master does not point to a valid object!
[16:35:39][Step 1/1] ERROR: error: refs/tags/1.3.0 does not point to a valid object!
[16:35:39][Step 1/1] ERROR: fatal: bad object HEAD

(the capture of the output may be wrong too, but at the moment I'm mostly concerned with the error it's throwing).

What have I done wrong here? I have set it to fetch all heads, so shouldn't it have all the info it needs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions