I have a devops yaml pipeline that runs DotNetCoreCLI@2 tasks to restore, build and test.
In the event, one or more tests fail I would like the pipeline to continue and publish the output ready for the devops release.
Initially, for a failed test the whole pipeline execution would report "Build Failed". After adding the following at the top of the build pipeline yaml:
jobs:
- job: Build
continueOnError: true
I now get "Build Partially Succeeded".
However, when I check the pipeline execution summary page, I see there are 0 artifacts:
How can I make the pipeline publish even if the tests fail?
For completeness, the full yaml is below
stages:
- stage: Build
jobs:
- job: Build
continueOnError: true
pool:
name: Hosted Windows 2019 with VS2019
demands:
- msbuild
- visualstudio
variables:
solution: '**/*.sln'
projects: '**/Interfaces.Avaloq.Presentation.AzureFunctions.csproj'
unitTestProjects: '**/*Testing.Unit*/*.csproj'
integrationTestProjects: '**/*Testing.Integration*/*.csproj'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- script: |
- task: DotNetCoreCLI@2
displayName: Restore Functions
inputs:
command: restore
projects: '$(projects)'
feedsToUse: config
nugetConfigPath: nuget.config
- task: DotNetCoreCLI@2
displayName: Build Functions
inputs:
command: build
projects: '$(projects)'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Restore Unit Tests
inputs:
command: restore
projects: '$(unitTestProjects)'
feedsToUse: config
nugetConfigPath: nuget.config
- task: DotNetCoreCLI@2
displayName: Build Unit Tests
inputs:
command: build
projects: '$(unitTestProjects)'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Run Unit Tests
inputs:
command: 'test'
projects: '$(unitTestProjects)'
arguments: --filter Category!=ExcludeFromBVT
testRunTitle: 'Unit Tests'
feedsToUse: config
nugetConfigPath: nuget.config
- task: AzurePowerShell@4
inputs:
azureSubscription: 'Design Subscription (xxx)'
ScriptType: 'InlineScript'
Inline: |
Set-Location $env:AGENT_WORKFOLDER
Get-ChildItem -Recurse
azurePowerShellVersion: 'LatestVersion'
- task: DotNetCoreCLI@2
displayName: Publish
inputs:
command: publish
arguments: '--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)'
projects: '$(projects)'
publishWebProjects: false
zipAfterPublish: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: ArmTemplate'
inputs:
PathtoPublish: Interfaces.Avaloq.Deployment
ArtifactName: RGDeploy
If your test are failing please add continueOnError: true
on test step level. Adding it on job level causes that next (dependent) job will run. Please compare this: