Q:

How to use Jenkins local defined variable in IF statement?

I have below code 
def result = readFile('res.txt')
echo "${result}"

if ("${result}" > 5 )

{ 
        echo "Yes"
    } else {
        echo "No"
    } 
}

It is printing NO but the answer in ${result} -> 11 which means it should print Yes. Can u pls help.

A:

As noted in comments - you should cast the result to integer. Both result.toInteger() and Integer.parseInt(result) will work, although the first one is more straightforward and doesn't complain about extra white space (e.g. trailing endline character).
Besides, you don't need to mess with strange constructs like "${result}" because result is a normal variable, so your code may look like this:
def result = readFile('res.txt')
echo "${result}"

if (result.toInteger() > 5 ) { 
    echo "Yes"
} else {
    echo "No"
}

