Is there a way to programatically pull the sprint number from JIRA from CLI or Groovy?

I want to automate our build so that we usually don't have to fiddle with our versions. Our versions follow the format:


Seems like I should be able to reach out to JIRA and grab that sprint number.