In our pipeline job , we have few stages
eg: this stage will start the automation job
stage('Run E2E tests') {
steps {
withCredentials([
sshUserPrivateKey(credentialsId: 'XXXXX', keyFileVariable: 'SSH_KEY_FILE', usernameVariable: 'SSH_USER')
]) {
sh """
eval `ssh-agent -s`
ssh-add ${SSH_KEY_FILE}
~/earthly \
--no-cache \
--config=.earthly/config.yaml \
+e2e
eval `ssh-agent -k`
"""
}
}
}
I am planning to add one more stage with validate the console out put like below
stage("Check Test Case Results"){
steps {
script{
if (manager.logContains('.*myTestString.*')) {
error("Build failed because of this and that..")
}else{
echo("No issues")
}
}
}
}
But above stage is not validating the if condition always going to else statement.