curl -s --user <username>:<password> --data-urlencode "tree=displayName" http://jenkins.teslamotors.com/job/firmware-repo/5111/api/json
1) Split your build step in two parts and use the envinject plugin.
Your first step will generate the build name and save to a file.
Then, you can inject that via the envibject plugin and use the set build name based on that property. Afterwards you can run your script.
2) if you don't mind running that action as part of the post build you could use the groovy y post build plugin.
3) if you use some system groovy script step you could rename your build name on the fly rather than as part of the post build action (have a look at the groovy plugin).
I hope it helps, maybe someone else already got another easy workaround
Cheers