I'm trying to run multiple commands in the script block but it reports not found
. If I add &&
double ampersand then it doesn't show up in the jenkins console at all and doesn't execute (as if its missing).
script {
unit_test_result = sh (
script: 'mvn clean test | grep \'Tests run:\' | grep -v \'Time elapsed\' & \'if [[ $? != 0 ]]; then echo \"No Unit tests to run!\"; fi\'',
returnStdout: true,
)
}
This is the error I'm getting..
[Pipeline] script)
[Pipeline]e)
[Pipeline] sh
+ + grep -v Time elapsedif [[ $? == 1]]; then echo "No Unit tests to run!"; fi
/home/test/jenkins/workspace/demo-web@tmp/durable-a86a2444/script.sh: 1: if [[ $? == 1]]; then echo "No Unit tests to run!"; fi: not found
+ grep Tests run:
+ mvn clean test
[Pipeline] }
[Pipeline] // script
[Pipeline] sh (