Groovy web console

subscribe to the feed Subscribe
to this
site
Check for regex in list (via #groovywebconsole)
tweet this snippet Tweet
this
script

Check for regex in list

Published 3 weeks ago by mika with tags gerrit ngcp
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
branch = 'mr5.5'

dirty_ngcp_releases = [
  '2.8', '3.0', '3.1', 'mr3.[2-8]*', 'mr4.[0-5]*', 'mr5.[0-4]*'
]

def unsupported_branch(String arg) {
    dirty_ngcp_releases.findAll {
        if("$arg" ==~ /${it}/) {
            return(1)
        }
    }
}

if (unsupported_branch(branch)) { 
    println("ney, $branch is NOT supported")
} else {
    println("jey, $branch is supported")
}