mercredi 23 mai 2018

How to find a sub-string from a string in a variable using groovy

I have a variable err = "http code 401"

now I want to do a if condition by reading that variable and if it finds 401 it should echo a message.

Something like,

if (${err}.contains('401')
{
    echo "Unauthorized"
}

The above works in java, how to implement the same in groovy.

Help Appreciated!

Aucun commentaire:

Enregistrer un commentaire