Naresh Ede
Naresh Ede

Reputation: 173

Could not find a 'develop' or 'master' branch, neither locally nor remotely. - Semantic gitversion

I have a repo in azure and it has the default branch "main".

Also, I have a task in yml file for semantic versioning.

- task: gittools.gitversion.gitversion-task.GitVersion@5
  displayName: Get Semantic Git Version 

I am hitting the below error

No branch configuration found for branch personal/release1, falling back to default configuration System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.

So, I just created a develop branch and triggered build then the semantic version got succeeded.

We do not want to maintain develop or master branch as per guidelines.

How can we overcome the error without maintaining the master and develop branch?

Thanks

Naresh Ede

Upvotes: 6

Views: 7532

Answers (2)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30343

GitVersion task is deprecated. It uses the an old version(5.0.1) of GitVersion, which caused above error. It is recommended to use GitTools bundle extension instead. You can install GitTools extension in your project. See below example;

- task: gitversion/setup@0
  displayName: Install GitVersion
  inputs:
    versionSpec: '5.x'
 
- task: gitversion/execute@0
  

Please check the document for more usages.

You can also use UseGitVersion task. And use the latest 5 version by specifying the versionSpec.

- task: UseGitVersion@5
  displayName: gitversion
  inputs: 
   versionSpec: 5.x
  enabled: true

Or you can use a GitVersion.yml config file as Krzysztof Madej mentioned to map the main branch to master branch.

mode: ContinuousDelivery
branches:
  master:
    regex: main
    mode: ContinuousDelivery

Upvotes: 3

Krzysztof Madej
Krzysztof Madej

Reputation: 40759

It looks that this is not supported yet by GitTools\GitVersion and it is still waiting for a solution.

But to overcome this you can provide GitVersion.yml file

mode: ContinuousDelivery
branches:
  master:
    regex: main
    mode: ContinuousDelivery
    tag:
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
  feature:
    regex: feature(s)?[/-]
    mode: ContinuousDeployment
  develop:
    regex: dev(elop)?(ment)?$
    mode: ContinuousDeployment
    tag: alpha
  hotfix:
    regex: hotfix(es)?[/-]
    mode: ContinuousDeployment
    tag: beta
  release:
    regex: release(s)?[/-]
    mode: ContinuousDeployment
    tag: rc
ignore:
  sha: []

And then use it like this

steps:
- task: GitVersion@5
  inputs:
    runtime: 'core'
    configFilePath: 'GitVersion.yml'
    updateAssemblyInfo: true

Upvotes: 5

Related Questions