I'm writing Jenkins pipeline in which I'm extracting Jira tickets from GIT commit message.I'm using JIRA ID regex. How can I process a multiline string? I also have to display commit messages which do not contain any valid ticket ID's. How can I do that using the if-else loop in groovy? Below logic works for a single line, but not working for multi-line.
def commit = """new change
CO-10389
SRE-1234"""
def regex = (/[\s|]?([A-Z]+-[0-9]+)[\s:|]?/)
if(commit =~ regex){
def jira = commit.readLines().findAll(/[\s|]?([A-Z]+-[0-9]+)[\s:|]?/)
println jira
} else {
println commit
}