Regarding Junit and Jacoco report publishing

I have one git repository from which I am building artifacts using Dynamic agent as ECS:
Project1 having top folder has Services/UI/DB and Automation
Automation contain jenkinsfile having maven test job.

  • Service
    • SRC
    • POm.xml
  • UI
  • DB
  • Automation
    • jenikinsfile-services
      My query is :slight_smile:
  1. Not able to publish the result
  2. How to use multiline shell command inside stage block

Hello @dxm007 and welcome to this community :wave:

To use a multiline shell command inside a stage block, you maybe could use the triple quotes ''' to define the shell script. Here’s an example:

stage('Publish Results') {
  steps {
    sh '''
      cd Automation
      mvn clean test
      cd target/surefire-reports
      cp -r * ${JENKINS_HOME}/test-results
    '''
    junit 'target/surefire-reports/*.xml'
  }
}

In this example, the cd command changes the directory to the Automation directory, then the mvn clean test command runs the Maven test job. The next cd command changes the directory to the target/surefire-reports directory, and the cp command copies the test result files to the ${JENKINS_HOME}/test-results directory.

The junit command then uses the *.xml pattern to find the test result files and publish them as JUnit test results.

Note that you would need to adjust the paths in this example to match the actual paths in your project.
Please note I did not take the time to test this example, so take it with a grain of salt.

@poddingue …thanks for your replay…
Looking for further support…i have one stage on my pipeline as mentioned below:
Stage (sonaranalysis){
Steps{
Sh ‘’’
Cd system/services
Sonarq analysis(
Env: ‘dev’,
Language: ‘java’,
Coverage: ‘test.xml’,)
‘’’
Error while execution: unexpected newline expecting (“)”)

Please assist me on this…thanks in advance

1 Like

@dxm007
can post the pipeline script if possible?

is this the script you have ?

stages {
        Stage('sonaranalysis') {
            Steps {
                sh '''
                cd system/services
                Sonarq analysis(
                Env: ‘dev’,
                Language: ‘java’,
                Coverage: ‘test.xml’,)
        '''
            }
}

stages {
Stage(‘sonaranalysis’) {
Steps {
sh ‘’’
cd system/services
Sonarq.analysis(
Env: ‘dev’,
Language: ‘java’,
Coverage: ‘test.xml’,)
‘’’
}
}
}

It is the script…please help me on this

what is Sonarq.analysis here? and you are passing some data into it

It is a function described in shared library and i am passing the argument to this function with different values required for sonar scanner.

When i build the pipeline and got shell error : unexpectedly new line…expected (“)”).

1 Like

It is a function described in shared library…i am using this funtion to do sonar analysis and passing multiple arguments to this.

While building the job , this stage throw below error:

Unexpected new line expecting (“)”).

try this @dxm007

stage('sonaranalysis') {
            steps {
                sh '''
                cd system/services
                Sonarq.analysis(
                Env: 'dev',
                Language: 'java',
                Coverage: 'test.xml',)
            '''
            }
        }

Hi,

Still facing the same issue…expected (“)”)…
Not able to proceed further…

Hi @dxm007 try this, if it doesn’t help then i will to reproduce the issue in my jenkins

Sonarq.analysis(
                Env: 'dev',
                Language: 'java',
                Coverage: 'test.xml').trim()

Hi Jana,

I tried all the permutation and combination, but no success.

Please help me on this.

Hm… something wrong with the script only
@dxm007 can you also post the screenshot of the pipeline stage which is failing

Hi JS,

Please find the attached screenshots and suggest me whats need to be done for issue …

Thank in advance

Thanks in advance