I am trying to run groovy script to extract ID from jira db
Connection conn = ConnectionFactory.getConnection(helperName);
log.debug("connection succees")
Sql sql = new Sql(conn)
def row;
StringBuffer sb = new StringBuffer()
try {
sql.eachRow("""select ji.id as 'ID' from jiraissue ji
left join project p with(nolock)
on ji.project = p.id
where p.pkey='SWRM' and ji.summary='19.10'""") {
//log.warn("${it}")
sb << "${it}"
}
sb.toString()
log.debug("sb value " +sb)
return sb
} finally {
sql.close()
}
sb is returning [ID:873319], but i just want to extract 873319 so that I can pass it to another field.
You could use the substring function to remove the first 4 and last characters.
sb.substring(4,sb.length()-1)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.