I'm trying to integrate Jenkins to grab stories from pivotal tracker which have been marked as finished if they have been included in a build (we already have integration with github on both jenkins and pivotal tracker). Using curl, I am able to grab related stories using pivotal's web api, which returns an xml with the story values. I have tested a bash regex (<current_state>(.*)<\/current_state>
) on regexraptor.net, to match the node value in a string (in this case, <story><current_state>this</current_state></story>
), with the goal of returning this
(the desired text from the element) for assignment to a bash variable. regexraptor tells me it matches, but when I try to get output the text, it comes up blank.
currently, my code to output goes like this:
$XML_STRING='<current_state>this</current_state>'
[[ $XML_STRING =~ '<current_state>(.*)<\/current_state>' ]]
echo "${BASH_REMATCH[1]}"
which outputs nothing. How can I get it to output 'this'?
Due to the constraints of the Oracle Linux distro on the server I'm using at work, I need to get this working using pure bash if possible. sed and grep are available, but I've had no luck with them- sed finds a match, but outputs the whole stream of xml rather than the single word value I want, and I just plain can't get grep working. xpath is unavailable, and xmllint has proved unworkable as well