I am trying to add a "validation" stage in Jenkinsfile based on the time. If it is later than 16, validation is required, otherwise not.
the if statement is not working
here I am declaring the variable
HOUR=sh(returnStdout: true, script: 'date +"%H"').trim().toInteger()
and here is the stage
stage('validation') {
steps {
script {
if ( HOUR > 16 ) {
echo "Validation is required, time now is $HOUR"
}
else {
echo "No validation required, time now is $HOUR"
}
}
}
}
and here is the output
Validation is required, time now is 9
the value of the variable HOUR is correct, but the if statement doesnt work correctly
thanks in advance