use def variable, when you want to compare any String. Use below code for that type of comparison.
def variable name = null
SQL query give you some return. Use function with return type def.
def functionname(def variablename){
return variable name
}
if ("$variable name" == "true"){
}