readTrusted is incompatible with parameterized branch names

We need to use readTrusted in order to access a file per branch. Unfortunately for pipelines that used parameterized branch names such as ${BRANCH} the parameter does not get expanded and we get an error.

confYaml = readTrusted('conf.yaml')

Will fail:

error: Command "git fetch --tags --force --progress --prune -- origin +refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH}" returned status code 128:
  stdout: 
  stderr: fatal: couldn't find remote ref refs/heads/${BRANCH}

Using multi branch pipelines our case is not an option as it would cause our Jenkins instances to run out of inodes due to the internal impact on the controller’s filesystem: we have a monorepo with hundreds of branches and hundreds of pipelines.

This is related to known bugs in the git plugin: