Run Jobs Sequentially
Learn how to break down the tests into jobs and how to reorganize the pipeline to use inside of a job.
So far, we have executed all tests in a single job.
The Priority variable is passed to the goals of the Maven task so the tests with the specific priority are executed:
goals: 'clean test -Dgroups=$(Priority)'
Let’s say that we want to execute tests sequentially by priority:
- First, the
Highpriority tests should run. - Then, the
Mediumpriority should run. - Finally, the
Lowpriority ones should run.
How to execute jobs sequentially
To execute jobs sequentially, we need to change the pipeline code as follows so that it uses jobs and strategies:
Press + to interact
trigger:- masterjobs:- job:pool:vmImage: 'ubuntu-latest'strategy:matrix:Tests_High:TestsPriority: "High"Tests_Medium:TestsPriority: "Medium"Tests_Low:TestsPriority: "Low"maxParallel: 1steps:- task: Bash@3displayName: "create browser variable"inputs:targetType: 'inline'script: |export BROWSER=$(BROWSER)- task: Maven@3inputs:mavenPomFile: 'pom.xml'mavenOptions: '-Xmx3072m'javaHomeOption: 'JDKVersion'jdkVersionOption: '1.8'jdkArchitectureOption: 'x64'publishJUnitResults: truetestResultsFiles: '**/surefire-reports/TEST-*.xml'goals: 'clean test -Dgroups=$(TestsPriority)'- task: PublishBuildArtifacts@1displayName: 'Publish Log File as Artifact'inputs:PathtoPublish: $(System.DefaultWorkingDirectory)/target/logsArtifactName: 'logs_$(TestsPriority)'- task: PublishBuildArtifacts@1displayName: 'Publish Screenshots as Artifact'inputs:PathtoPublish: $(System.DefaultWorkingDirectory)/target/screenshotsArtifactName: 'screenshots_$(TestsPriority)'
The pipeline has a jobs section, which can include one job or more (line 4). ...
Ask