The following conditional works as expected when run from the bash command line on my Jenkins server:
if (($BRANCH_COUNT > 0)); then .....
But when running in the context of a Jenkins pipeline step (calling sh ''' .... '''
), it writes an error and always evaluates to false. The error message (below) suggests maybe it's interpreting the value of $BRANCH_COUNT (in this case it is 1) as a command, which is then not found?
/var/jenkins/workspace/deploy-config-db-update@tmp/durable-baa54bb3/script.sh: 16:
/var/jenkins/workspace/deploy-config-db-update@tmp/durable-baa54bb3/script.sh: 1: not found
Is there something different about the bash environment when run by the Jenkins sh
command? Some special escaping or quoting needed?