-
Bug
-
Resolution: Not A Defect
-
Blocker
Hello,
I am using the groovy to use the insatlled TestNG plugin but doesn't work. Below are the errors i get while using this: step([$class: 'Publisher']): Publish TestNG Results
88: expecting ')', found ':' @ line 88, column 35.
[($class: 'Publisher') : Publish TestNG Results, reportFilenamePattern: './target/surefire-reports/testng-results.xml']
^
WorkflowScript: 7: Expected a step @ line 7, column 51.
([$class: 'Publisher']) : Publish ........
^
WorkflowScript: 8: unexpected token: TestNG @ line 8, column 33.
Publish TestNG Results
^
java.lang.NoSuchMethodError: No such DSL method 'publishers' found among steps
88: expecting ')', found 'Publisher' @ line 88, column 36.
[($class 'Publisher') Publish TestNG Results, reportFilenamePattern: './target/surefire-reports/testng-results.xml']
^
I have referred to many TestNG plugin documentations including:
https://www.jenkins.io/doc/pipeline/steps/testng-plugin/#stepclass-publisher-publish-testng-results
but the issue doesn't get resolved.
Kindly let me know if we can use this plugin using groovy.
i have tried using it under pipeline, stages, steps, have tried all the possible combinations but doesn't work
Groovy :
{ def scmVars1 = checkout([$class: 'GitSCM', branches: [[name: params.branch ]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'bitbucket-login', url: params.scmurl]]]) }/* (c) Boots Co. All rights reserved.*/
/* Jerry Brimaocmbe - Stand alone job to be run with parameters */
def call(body) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()
def label = "sdet${UUID.randomUUID().toString()}"
podTemplate(
label: label,
name: label,
imagePullSecrets: ['nonprodregistry'],
containers: [
containerTemplate(
name: 'jnlp',
image: 'gcpdevacr.azurecr.io/jenkins/jnlp-slave:v4.3.4',
envVars: [
envVar(key: 'JENKINS_URL', value: 'https://npjenkins.tools.boots.com'),
envVar(key: 'JENKINS_TUNNEL', value: 'jenkins-agent:50000')
]
),
containerTemplate(
name: label,
image: 'gcpdevacr.azurecr.io/baseimg/wag-dotcom-build-chrome-bionic:v2',
command: 'cat',
ttyEnabled: true,
alwaysPullImage: true,
resourceRequestCpu: '500m',
resourceLimitCpu: '2000m',
resourceRequestMemory: '512Mi',
resourceLimitMemory: '2048Mi'
)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
]
){
node(label) {
container(label) {
stage('Clone') {
dir(params.MicroserviceName) {
try {
dir('dhpuiautomation')
} catch (exc)
{ currentBuild.result = "FAILURE" throw exc } finally { currentBuild.displayName = "#" + env.BUILD_NUMBER + " " + params.desc currentBuild.description = params.desc }}
}
stage ('UI Functional Test') {
dir(params.MicroserviceName) {
try {
dir('dhpuiautomation') {
sh 'google-chrome --version'
configFileProvider([configFile(fileId: 'f515c588-9321-4551-8906-18cfc0d33b78', variable: 'mavensettings')]) {
def mvnComman = '''mvn -X -s $mavensettings ''' + params.mvnCommand
echo mvnComman
sh 'echo "Start test $(date +"%Y%m%d%H%M")"'
sh "${mvnComman}"
echo "mvn finished"
sh 'echo "End test $(date +"%Y%m%d%H%M")"'
sh 'ls -Rltr'
}
}
} catch (exc) { currentBuild.result = "FAILURE" throw exc }
finally {
{ sh 'mkdir -p target/allure-results' sh 'cp -r ../dhpuiautomation/target/allure-results/* target/allure-results/.' sh 'chown -R 10000:10000 target' sh 'chmod -R 777 target/' }dir('dhpapiautomation')
allure([results:[[path: 'dhpapiautomation/target/allure-results']]])
step([$class: 'Publisher', reportFilenamePattern: '**/testng-results.xml'])
}
}
}
}
}
}
}