I would like to run the following regex modifer within my Jenkins pipeline. I have done the following:
pipeline {
options {
disableConcurrentBuilds()
timestamps ()
buildDiscarder(logRotator(numToKeepStr: ‘30’, artifactNumToKeepStr: ‘30’))
timeout(time: 45, unit: ‘MINUTES’)
}
agent {
label “jenkins-slave”
}
libraries {
lib(‘ishared-lib’)
}
stages {
stage(‘Deploy stage’) {
steps {
script {
sh ‘echo’
presetUsersRaw = sh(
script: “”“curl --request GET --url ‘xxxxxxxxxxxx’ --header ‘Accept: application/+json;version=2’ --header ‘Authorization: Token token=xxxxxxxxxxxx’ --header ‘Content-Type: application/json’| jq ‘.users.email’”“”,
returnStdout: true
).trim()
def search = /(\W+)$/gm
echo “${presetUsersRaw}”
presetUsersRaw = presetUsersRaw.replaceAll(‘@domain.com’,‘’)
echo “${presetUsersRaw}”
//presetUsersRaw = presetUsersRaw.replaceAll(’ ‘,’.‘)
//echo “${presetUsersRaw}”
presetUsersRaw = presetUsersRaw.replaceAll(’"', ‘@’)
echo “${presetUsersRaw}”
presetUsersRaw = presetUsersRaw.replaceAll(search , ‘’)
echo “${presetUsersRaw}”
}
}
}
}
}
So I tried adding “gm” to the end of the “search” variable, thinking this would work on jenkins as I tested this out on a regex tester for groovy. However I got a:
groovy.lang.MissingPropertyException: No such property: m for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63)
Is there anyway to implement global and multiline modifiers? I am fairly new at regex and trying this out as I go.