I have a script that generates a version string based on the current git commit and history. I want to use that version string for the docker images too. However, I can’t seem to figure out a way to run this script/program and then use its output version with the docker plugin.
I know that environment variables are filled in before any steps run, so I can understand why this doesn’t work. Then, how can I possibly use a tag name generated at run-time with the docker plugin?
The reason this example does not work is because it is not possible at the unix level. One cannot create an environment variable in one process, and read that environment variable in a sibling process. We can reproduce the same results with these shell commands:
If you need to share data between sibling processes (pipeline steps) you need to share this information by writing to and reading from disk. The docker plugin will automatically read tags from a .tags file, which means you can do this:
I’d gladly do that, but I can’t seem to figure out where the docs live. drone/docs doesn’t seem like it, and the plugin repo itself has no docs. Perhaps the pages should link to their source files on GitHub, to make it trivial to find what page to contribute to.
drone/docs is live, but this represents the drone core documentation. Plugins are completely separate entities and are documented at plugins.drone.io. The source is found here github.com/drone/drone-plugin-index