I've tried this:
// Check for availability of "formail", which should be included in packages for "procmail" def formailPath = 'which formail'.execute().text.trim() assert formailPath > '', 'Programm "formail" is needed. Please install package procmail'
and it worked quite well, since the expression 'which formail'.execute().text.trim() returns either the empty string or the path to the executable.