[Solved] How can I check if an XML response contains a pattern? [closed]

In Groovy, you can use the following check (assuming text is the variable holding the string you provided in the question): if (text=~/Server returned HTTP response code: 503\b/){ println “503 code detected” } else { println “503 code not detected” } But it also seems you can just use contains: if (text.contains(‘HTTP response code: 503 … Read more

[Solved] Groovy script to change the svn url in jenkins jobs

Does it have to be a Groovy script? I would simply login to the Jenkins master host and run this sed oneliner: $ sed -i ‘s#svn://old-url#svn://new-url#g’ \ “$JENKINS_HOME”/jobs/*/config.xml and reload the configuration from disk. 0 solved Groovy script to change the svn url in jenkins jobs

[Solved] Split a string in groovy

You can use the Java split(regex) method to achieve your first goal and then groovy syntactic sugar to help with the rest: def str = “,,,,,” def arr = str.split(/,/, -1) println arr.size() // 6 arr[0] = 1 arr[1] = 2 arr[2] = 3 println arr // [1, 2, 3, , , ] See also … Read more

[Solved] Replacing string with variable with Groovy and SED command

In Groovy variable/expression substitution inside of strings (interpolation) only works with certain types of string literal syntax. Single quote syntax (‘content’) is not one of them. However, if you replace the outer single quotes with double quotes (“content”) then you should get the interpolation effect you are looking for: def sDescription = “foo” def sedCommand … Read more