Pipeline `sh` sometime is used to compute value to be later used by pipeline as a groovy variable. Same happens in a classic shell script, but on can use `foo = $(some command)` in such circumstances. Would be nice to have pipeline support something comparable.
Not sure something as simple as `def foo = sh 'some command'` can be achieved, then a dedicated syntax would be required.
Some use to dump value in shell script into a text file, then use `readFile` in Pipeline to parse and assign to a groovy variable, This only can be considered a workaround imho, as this makes the Pipeline script heavy to read.