The question is, other than the predefined variables (list here), is it possible to publish a custom variable in the first pipeline so it's available later as a resource variable?
I am afraid there is no such directly way to publish a custom variable in the first pipeline as a resource variable at this moment.
As workaround, we could use the REST API in the rescource pipeline to update the variable in the Variables tab for the current pipeline.
Steps:
Define a variable in the later pipeline definition Variable.
Add a task to invoke REST API (Definitions - Update) in rescource pipeline to update the value of the above variable in the later release pipeline.
Use the updated value of the later pipeline variable in the later pipeline.
The details info about using REST API to update the value of the definition variable, you can follow the below ticket:
How to modify Azure DevOps release definition variable from a release task?
or you could use the Azure CLI to update the variable:
az pipelines variable update --name
[--allow-override {false, true}]
[--detect {false, true}]
[--new-name]
[--org]
[--pipeline-id]
[--pipeline-name]
[--project]
[--prompt-value {false, true}]
[--secret {false, true}]
[--subscription]
[--value]