Persisting state across run steps

I recently published an Orb to report build status to a Microsoft Teams channel. My orb exposes two commands for doing this. There are three basic run steps in the Orb. The first initializes information such as the last commit message and the message template to be sent to Teams. The second and third steps are invoked conditionally to either report a build success or failure. The initialization step sets up common data which is used for both the success and failure cases. I could not find a way to pass data from the initialization step into the subsequent run steps. I ended up resorting to placing statically named files in /tmp which the subsequent steps know about. Is there another mechanism available for persisting information between run steps other than named files on the file system or some other external database?

I realize that since jobs run in their own dedicated Docker containers there is not much of a risk of another build accessing these temp files. However, my solution seems a bit kludgey. I also considered using environment variables or Orb parameters. However, I don’t want the user of my Orb to have to worry about its internal implementation details.

Hi Ryan,

Would a Workspace fit your needs?

1 Like