Не удается получить конвейеры выпуска DevOps Azure, когда я включаю покрытие кода - PullRequest
1 голос
/ 14 мая 2019

Поэтому я пытаюсь настроить YAML для новых унифицированных конвейеров сборки и выпуска, но сталкиваюсь с проблемами при публикации результатов покрытия кода в сборке ...

Ошибка, которую я получаю, когда включаю отчет о покрытии кода:

Job Job1: Step Download_Code Coverage Report_870 has an invalid name. Valid names may only contain alphanumeric characters and '_' and may not start with a number.

Когда я настраиваю его так, он работает, но я не получаю результаты покрытия кода:

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
  - master

variables:
  buildConfiguration: 'Release'
  system.debug: true

stages:
  - stage: BuildAndDeploy
    displayName: Test
    jobs:
      - job: Quality
        displayName: Get Test Coverage and Code Quality
        pool:
          vmImage: 'ubuntu-latest'
        steps:
          # Install the latest version of the dotnet sdk
          - task: DotNetCoreInstaller@0
            displayName: 'Use .NET Core sdk 2.2.103'
            inputs:
              version: 2.2.103

          - script: dotnet build --configuration $(buildConfiguration)
            displayName: 'dotnet build $(buildConfiguration)'

          - script: dotnet test --configuration $(buildConfiguration) --logger trx --no-build
            displayName: 'dotnet test --configuration $(buildConfiguration) --logger trx --no-build'

          - task: PublishTestResults@2
            inputs:
              testRunner: VSTest
              testResultsFiles: 'test/**/*.trx'

          - task: DotNetCoreCLI@2
            displayName: Package Artifact
            inputs:
              command: 'publish'
              arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
              zipAfterPublish: True
              publishWebProjects: true
              feedsToUse: 'select'
              versioningScheme: 'off'

          - task: PublishPipelineArtifact@0
            inputs:
              artifactName: 'FakeApiServer'
              targetPath: '$(Build.ArtifactStagingDirectory)/FakeApi.Server.AspNetCore.zip'

  - stage: DeployTest
    dependsOn: BuildAndDeploy
    condition: and(succeeded(), not(eq(variables['Build.SourceBranch'], 'refs/heads/master')))
    displayName: Deploy To Test
    jobs:
    - deployment: DeployToTest
      environment: Testing
      pool:
        vmImage: 'ubuntu-latest'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: DownloadPipelineArtifact@1
              inputs:
                buildType: 'current'
                artifactName: 'FakeApiServer'
                targetPath: '$(System.ArtifactsDirectory)'

            - task: AzureRmWebAppDeployment@4
              displayName: Deploy to https://fake-api-test.azurewebsites.com
              inputs:
                ConnectionType: 'AzureRM'
                azureSubscription: 'Fake API Personal Azure Subscription'
                appType: 'webApp'
                WebAppName: 'fake-api-test'
                Package: $(System.ArtifactsDirectory)/*.zip
                enableCustomDeployment: true
                DeploymentType: 'zipDeploy'

  - stage: DeployProd
    dependsOn: BuildAndDeploy
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
    displayName: Deploy To Prod
    jobs:
    - deployment: DeployToProd
      environment: Production
      pool:
        vmImage: 'ubuntu-latest'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: DownloadPipelineArtifact@1
              inputs:
                buildType: 'current'
                artifactName: 'FakeApiServer'
                targetPath: '$(System.ArtifactsDirectory)'

            - task: AzureRmWebAppDeployment@4
              displayName: Deploy to https://fake-api.azurewebsites.com
              inputs:
                ConnectionType: 'AzureRM'
                azureSubscription: 'Fake API Personal Azure Subscription'
                appType: 'webApp'
                WebAppName: 'fake-api'
                Package: $(System.ArtifactsDirectory)/*.zip
                enableCustomDeployment: true
                DeploymentType: 'zipDeploy'

Но когда я включаю выполнение и создание отчетов о покрытии кода, этап развертывания завершается неудачно:

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
  - master

variables:
  buildConfiguration: 'Release'
  system.debug: true

stages:
  - stage: BuildAndDeploy
    displayName: Test
    jobs:
      - job: Quality
        displayName: Get Test Coverage and Code Quality
        pool:
          vmImage: 'ubuntu-latest'
        steps:
          # Install the latest version of the dotnet sdk
          - task: DotNetCoreInstaller@0
            displayName: 'Use .NET Core sdk 2.2.103'
            inputs:
              version: 2.2.103

          - script: dotnet tool install --global coverlet.console
            displayName: 'Install coverlet'

          - script: dotnet tool install -g dotnet-reportgenerator-globaltool
            displayName: 'install reportgenerator'

          - script: dotnet build --configuration $(buildConfiguration)
            displayName: 'dotnet build $(buildConfiguration)'

          - script: dotnet test --configuration $(buildConfiguration) /p:Exclude="[xunit*]*" /p:CollectCoverage=true /p:CoverletOutputFormat=\"opencover,cobertura\" --logger trx --no-build
            displayName: 'dotnet test --configuration $(buildConfiguration) /p:Exclude="[xunit*]*" /p:CollectCoverage=true /p:CoverletOutputFormat="opencover,cobertura" --logger trx --no-build'

          - script: reportgenerator -reports:test/**/coverage.cobertura.xml -targetdir:coveragereport -reporttypes:"HtmlInline_AzurePipelines;Cobertura"
            displayName: 'reportgenerator -reports:test/**/coverage.cobertura.xml -targetdir:coveragereport -reporttypes:"HtmlInline_AzurePipelines;Cobertura"'

          - task: PublishTestResults@2
            inputs:
              testRunner: VSTest
              testResultsFiles: 'test/**/*.trx'

          - task: PublishCodeCoverageResults@1
            displayName: 'Publish code coverage'
            inputs:
              codeCoverageTool: Cobertura
              summaryFileLocation: '$(Build.SourcesDirectory)/coveragereport/Cobertura.xml'

          - task: DotNetCoreCLI@2
            displayName: Package Artifact
            inputs:
              command: 'publish'
              arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
              zipAfterPublish: True
              publishWebProjects: true
              feedsToUse: 'select'
              versioningScheme: 'off'

          - task: PublishPipelineArtifact@0
            inputs:
              artifactName: 'FakeApiServer'
              targetPath: '$(Build.ArtifactStagingDirectory)/FakeApi.Server.AspNetCore.zip'

  - stage: DeployTest
    dependsOn: BuildAndDeploy
    condition: and(succeeded(), not(eq(variables['Build.SourceBranch'], 'refs/heads/master')))
    displayName: Deploy To Test
    jobs:
    - deployment: DeployToTest
      environment: Testing
      pool:
        vmImage: 'ubuntu-latest'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: DownloadPipelineArtifact@1
              inputs:
                buildType: 'current'
                artifactName: 'FakeApiServer'
                targetPath: '$(System.ArtifactsDirectory)'

            - task: AzureRmWebAppDeployment@4
              displayName: Deploy to https://fake-api-test.azurewebsites.com
              inputs:
                ConnectionType: 'AzureRM'
                azureSubscription: 'Fake API Personal Azure Subscription'
                appType: 'webApp'
                WebAppName: 'fake-api-test'
                Package: $(System.ArtifactsDirectory)/*.zip
                enableCustomDeployment: true
                DeploymentType: 'zipDeploy'

  - stage: DeployProd
    dependsOn: BuildAndDeploy
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
    displayName: Deploy To Prod
    jobs:
    - deployment: DeployToProd
      environment: Production
      pool:
        vmImage: 'ubuntu-latest'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: DownloadPipelineArtifact@1
              inputs:
                buildType: 'current'
                artifactName: 'FakeApiServer'
                targetPath: '$(System.ArtifactsDirectory)'

            - task: AzureRmWebAppDeployment@4
              displayName: Deploy to https://fake-api.azurewebsites.com
              inputs:
                ConnectionType: 'AzureRM'
                azureSubscription: 'Fake API Personal Azure Subscription'
                appType: 'webApp'
                WebAppName: 'fake-api'
                Package: $(System.ArtifactsDirectory)/*.zip
                enableCustomDeployment: true
                DeploymentType: 'zipDeploy'

Опять же, я получаю ошибку:

Job Job1: Step Download_Code Coverage Report_870 has an invalid name. Valid names may only contain alphanumeric characters and '_' and may not start with a number.

Я был в Build 2019 и говорил с ребятами из Azure DevOps на их стенде, и они, казалось, думали, что это скорее всего ошибка в системе, но я до сих пор не получил от них ответа, поэтому решил, что увижу если у кого-то здесь были какие-либо идеи.

Действительно странная часть в том, что я никогда говорю ему загрузить артефакт отчета о покрытии кода ... он просто решает загрузить все это самостоятельно и терпит неудачу, прежде чем он когда-либо доберется до загрузки. Определен шаг артефакта конвейера.

Ответы [ 2 ]

0 голосов
/ 16 мая 2019

Вы можете попробовать расширение ReportGenerator: https://marketplace.visualstudio.com/items?itemName=Palmmedia.reportgenerator (по крайней мере, это экономит некоторое время сборки, поскольку вам не нужно устанавливать его во время сборки)

Также я столкнулся с несколькими проблемами сборки сегодня и, похоже, связан с использованием vmImage, установленного в 'ubuntu-latest'.

Я вижу, что на некоторых сборках файловая система будет выглядеть так:

/home/vsts/agents/2.150.3/d:\a/1/s/

Принимая во внимание, что это должно быть:

/home/vsts/work/1/s/

После переключения на 'Ubuntu 16.04', похоже, он вернулся в нормальное состояние.

0 голосов
/ 14 мая 2019

У меня та же проблема, но я думаю, что она связана с заданием развертывания, когда я использую стандартное задание с теми же шагами - проблема не появилась. Также я заметил, что мое задание развертывания запускается на агенте сервера, даже если настроен пул: vmImage: ubuntu-latest

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...