Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63717

Not able to use TestNG Results Plugin in Jenkins

    Details

    • Similar Issues:

      Description

      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
       

       

       

        Attachments

        1. jenkins1.PNG
          jenkins1.PNG
          299 kB
        2. jenkins2.PNG
          jenkins2.PNG
          310 kB
        3. jenkins3.PNG
          jenkins3.PNG
          267 kB
        4. jenkins4.PNG
          jenkins4.PNG
          268 kB

          Activity

          Hide
          uzair_bhat uzair bhat added a comment -

          Groovy :
          /* (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')

          { def scmVars1 = checkout([$class: 'GitSCM', branches: [[name: params.branch ]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'bitbucket-login', url: params.scmurl]]]) }

          } 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 {
          dir('dhpapiautomation')

          { 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/' }

          allure([results:[[path: 'dhpapiautomation/target/allure-results']]])
          step([$class: 'Publisher', reportFilenamePattern: '**/testng-results.xml'])

          }
          }
          }
          }
          }
          }
          }

          Show
          uzair_bhat uzair bhat added a comment - Groovy : /* (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') { def scmVars1 = checkout([$class: 'GitSCM', branches: [[name: params.branch ]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'bitbucket-login', url: params.scmurl]]]) } } 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 { dir('dhpapiautomation') { 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/' } allure([results:[ [path: 'dhpapiautomation/target/allure-results'] ]]) step( [$class: 'Publisher', reportFilenamePattern: '**/testng-results.xml'] ) } } } } } } }
          Hide
          uzair_bhat uzair bhat added a comment -

          have use the below in all formats:

          step([$class: 'Publisher', reportFilenamePattern: '**/testng-results.xml'])

          also used this:

          publishers {
          archiveTestNG('*/target/test-reports/.xml')

          Throws error saying , no DSL for publishers
          No DSL as archiveTestNG

          Show
          uzair_bhat uzair bhat added a comment - have use the below in all formats: step( [$class: 'Publisher', reportFilenamePattern: '**/testng-results.xml'] ) also used this: publishers { archiveTestNG('* /target/test-reports/ .xml') Throws error saying , no DSL for publishers No DSL as archiveTestNG

            People

            • Assignee:
              nullin Nalin Makar
              Reporter:
              uzair_bhat uzair bhat
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: