Can we update the drone context in between so that we access that from later coming pipeline steps?

We’ve pinned some external repository’s commit ids for the tests. Before running the tests, these repositories are cloned in the preceding steps of the pipeline. We’re thinking about caching these types of pinned repositories so that we do not have to clone them for each build.

We want to store these cache with the commit id which is saved inside a file .drone.env. Inside the commands section, we can access the pinned branches inside the env file by sourcing it. But outside of the commands section, we cannot access that value, at least I’m not aware of.

If we can update the drone context ctx by some API, we can save that value in the context from the commands section and use it in the following steps from ctx.

Can we do so? Or is there any way to access such values outside of the commands section?

Thank you.