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
Not able to publish the result
How to use multiline shell command inside stage block
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 (“)”)