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

[ISSUE]: gitversion/execute@1 task uses branch from wrong repository #4004

Open
2 tasks done
Nexus20 opened this issue Apr 17, 2024 · 0 comments
Open
2 tasks done

[ISSUE]: gitversion/execute@1 task uses branch from wrong repository #4004

Nexus20 opened this issue Apr 17, 2024 · 0 comments

Comments

@Nexus20
Copy link

Nexus20 commented Apr 17, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

AzureDevops task

GitVersion version

5

Operating system

N/A

What are you seeing?

Hi everyone. I have two repositories in Azure Devops: first with pipelines YAML code and second with Nuget packages code and Girversion config file.

I have such pipeline code

parameters:
  - name: branchName
    displayName: Branch name for repository to use code from for manual launch (feature/* - for features, hotfix/* - for hotfixes, release/* - for releases, main - for main branch, dev - for dev branch)
    type: string
    default: dev

resources:
  repositories:
    - repository: nuget_repository
      type: git
      name: NugetProject/NugetRepo
      ref: ${{ parameters.branchName }}
      trigger:
        branches:
          include:
            - main
            - dev
            - release/*

trigger: none

pool:
  vmImage: ubuntu-latest

stages:
- stage: TestAndBuild
  displayName: 'Build, test and publish packages'

  jobs:
  - job: CreatePackages
    displayName: Build, test and publish packages
    workspace:
      clean: all
    steps:
    - checkout: nuget_repository
      fetchDepth: 0
      
    - task: gitversion/setup@1
      inputs:
        versionSpec: '5.x'

    - task: gitversion/execute@1
      displayName: Determine Version
      inputs:
        useConfigFile: true
        configFilePath: ./GitVersion.yml

    - script: echo current version is $(GitVersion.SemVer)
      displayName: 'Display calculated version'
      
    - task: Bash@3
      inputs:
        targetType: 'inline'
        script: echo "##vso[task.setvariable variable=version]$(GitVersion.SemVer)"
      displayName: 'Update build number'
      
    - task: DotNetCoreCLI@2
      displayName: Restore packages
      inputs:
        command: 'restore'
        projects: '**/*.csproj'
        feedsToUse: 'select'
        vstsFeed: 'NugetFeed'

    - task: DotNetCoreCLI@2
      displayName: Build project
      inputs:
        command: 'build'
        projects: '**/*.csproj'

    - task: DotNetCoreCLI@2
      displayName: Run tests
      inputs:
        command: 'test'
        projects: '**/*[Te]ests/*.csproj'
        arguments: '--configuration Release --collect "XPlat Code coverage" -- RunConfiguration.DisableAppDomain=true'
        testRunTitle: PortalTestsRun

    - script: 'dotnet tool update --global dotnet-reportgenerator-globaltool'
      displayName: 'Install or update ReportGenerator'
      condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
    
    - script: 'reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"'
      displayName: 'Generate Code Coverage report'
      condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
      
    - task: PublishCodeCoverageResults@1
      displayName: 'Publish Code Coverage report'
      inputs:  
        codeCoverageTool: Cobertura
        summaryFileLocation: '$(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml'
      condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))

    - task: NuGetCommand@2
      displayName: Pack projects into packages
      condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
      inputs:
        command: 'pack'
        packagesToPack: 'NugetRepo/src/**/*.csproj'
        versioningScheme: byEnvVar
        versionEnvVar: GitVersion.SemVer

    - task: NuGetCommand@2
      displayName: Push packages to feed
      condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
      inputs:
        command: 'push'
        packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
        nuGetFeedType: 'internal'
        publishVstsFeed: 'FeedId'

During pipeline execution gitversion/execute@1 task reads Gitversion config file from NugetRepo, but instead of using branch names from that NugetRepo, it uses branch name form repo with pipelines YAML code.

What is expected?

I'm running pipeline from dev branch of infrastructure repo using feature/123 branch of Nuget packages repo.
I'm expecting to have package with 1.0.0-feature/123 version, but instead I'm having 1.0.0-dev
изображение
изображение

Steps to Reproduce

Create repo with pipeline.
Create repo with packages.
Run pipeline.

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant