I've defined If-Else in the jenkins script section. But it doesn't get executed at all. Any idea what's wrong.
script {
unit_test_result = sh (
script: ''' #!/bin/bash
mvn clean test | grep \'Tests run:\' | grep -v \'Time elapsed\'
if [[ $? == 1 ]];
then echo "No Unit tests to run!";
fi
''',
returnStdout: true
).trim()
}
But the if section doesn't run at all..
[Pipeline] script
[Pipeline]
[Pipeline]
+ grep Tests run:
+ mvn clean test
+ grep -v Time elapsed
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
Failed in branch Unit Tests