Using GitVersion with BitBucket Cloud Pipelines
Asked by Vishal Kashi:

Hi am using GitVersion for bitbucket pipeline but the build is failing with this error  

<br />

    + dotnet-gitversion /buildserver

    Unhandled exception. GitVersion.WarningException: Could not parse command line parameter '/buildserver'. If it is the target path, make sure it exists.

       at GitVersion.ArgumentParser.ParseTargetPath(Arguments arguments, String name, IReadOnlyList`1 values, String value, Boolean parseEnded) in D:\a\GitVersion\GitVersion\src\GitVersion.App\ArgumentParser.cs:line 190

       at GitVersion.ArgumentParser.ParseArguments(String[] commandLineArguments) in D:\a\GitVersion\GitVersion\src\GitVersion.App\ArgumentParser.cs:line 86

       at GitVersion.Program.<>c__DisplayClass4_0.<CreateHostBuilder>b__2(IServiceProvider sp) in D:\a\GitVersion\GitVersion\src\GitVersion.App\Program.cs:line 30

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)

       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)

       at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)

       at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)

       at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)

       at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)

       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)

       at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)

       at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

       at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

       at GitVersion.Program.Main(String[] args) in D:\a\GitVersion\GitVersion\src\GitVersion.App\Program.cs:line 15

       at GitVersion.Program.<Main>(String[] args)

This is the pipeline file I am using

```
image: mcr.microsoft.com/dotnet/sdk:6.0

clone:

depth: full

pipelines:

default:

- step:

name: Version and build

script:

- export PATH="$PATH:/root/.dotnet/tools"

- dotnet tool install --global GitVersion.Tool --version 5.*

- dotnet-gitversion /buildserver

- source gitversion.properties

- echo Building with semver $GITVERSION_FULLSEMVER

- dotnet build
```


Answers:
author: Theodora Boudale
body: Hi [@Vishal Kashi](/t5/user/viewprofilepage/user-id/5135191) and welcome to the community!

The output from the command you posted here mentions the following:

```
Could not parse command line parameter '/buildserver'. If it is the target path, make sure it exists.
```

Pipelines builds run in Docker containers and your Docker container doesn't have a directory **/buildserver**.

I am not familiar with GitVersion and I am not sure which directory you need to give as an argument.

In case you need to provide the directory of the repo's clone:

* When a Pipelines build runs, the repo is cloned in the directory **/opt/atlassian/pipelines/agent/build** in that container. This is also the present working directory where your build's commands are executed unless, of course, you change directories.  
  The clone directory is exposed in the variable $BITBUCKET_CLONE_DIR and you can use  

  ```
  - dotnet-gitversion $BITBUCKET_CLONE_DIR
  ```

If you need to provide another directory as an argument, then based on the error message, you will first need to create that directory.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud