Firstly, you must have the permissions to create, edit and delete the pipeline in the project. If you do not have the permissions, you need to contact the project administrators.
Suppose the variable for the configurations is Configuration = Debug,Release
.
To run a task in the pipeline only for a certain configuration:
- If your pipeline is created using the classic editor, you can do like as the steps shown on the screenshots below.
- Set the
Configuration
variable in pipeline
- Set the Multi-configuration job, and add condition to skip the Visual Studio Test task when the
Configuration
is Debug
.
- If your pipeline is created using YAML.
- Using
if
conditional to skip the Visual Studio Test task.
jobs:
- job: Build
strategy:
maxParallel: 2
matrix:
DEBUG:
Configuration: Debug
RELEASE:
Configuration: Release
steps:
- task: Bash@3
displayName: 'Show current Configuration'
inputs:
targetType: 'inline'
script: 'echo "Configuration = $(Configuration)"'
. . .
- ${{ if eq(variables['Configuration'], 'Release') }}:
- task: VSTest@2
displayName: 'VsTest - testAssemblies'
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
In this way, when the Configuration
is Debug
, the Visual Studio Test task will be skipped and hidden in the job run.
- Using
condition
to skip the Visual Studio Test task.
jobs:
- job: Build
strategy:
maxParallel: 2
matrix:
DEBUG:
Configuration: Debug
RELEASE:
Configuration: Release
steps:
- task: Bash@3
displayName: 'Show current Configuration'
inputs:
targetType: 'inline'
script: 'echo "Configuration = $(Configuration)"'
. . .
- task: VSTest@2
displayName: 'VsTest - testAssemblies'
condition: eq(variables['Configuration'], 'Release')
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
In this way, when the Configuration
is Debug
, the Visual Studio Test task will be skipped but not hidden in the job run.