abhilash mt
abhilash mt

Reputation: 35

How to add tags in the maven goal in azure pipeline yaml file

I need to add a maven goal in azure pipeline yaml file which contains @tag, when i do so it is throwing some error saying @ is not allowed.

mvn test -Dcucumber.options="--tags '~@skip_scenario and @Regression'"

this is the goal i need to add in the yaml file

YAML: trigger:

pool: vmImage: 'windows-latest'

steps:

Error: [ERROR] Unknown lifecycle phase "@Smoke"". You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

Upvotes: 1

Views: 3253

Answers (1)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35514

Test with the Yaml and I could reproduce it.

The cause of this issue is that the goals field in the Maven task doesn't support the command.

According to this doc:

The Lifecycle contains validate,compile,test, package,verify ,install, deploy.

The command you used to add tags is the Maven command-line. You could add the command in the Option field.

For example:

- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'test'
    options: 'test -Dcucumber.options="--tags @Smoke"'
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    mavenVersionOption: 'Default'
    mavenAuthenticateFeed: false
    effectivePomSkip: false
    sonarQubeRunAnalysis: false

Here is the doc about the Maven task.

Hope this helps.

Upvotes: 1

Related Questions