Adding and extracting a variable from a build

Currently trying to extract build metadata from bamboo. I was successfully able to achieve this with a Tasktype module. What would be the best way for me to add this variable to the build and to extract the variable later (using say BuildCompleteAction or buildProcessor)?