I recently found out we have access to a different number that could be used instead of the job number in our commands.
https://circleci.com/docs/2.0/configuration-reference/#using-pipeline-values
This gives us access to << pipeline.number >> which would be a better identifier for the pipeline version.
Things to consider:
- This removes the need to have workspace persistence as I've checked and the number is consistent within a pipeline
- This could remove the need for a version file also, but it might be worth leaving it in as an option?
- This number is set on first run, re-runs of the same build will keep the same number.