This value should be known before the SCM is checked out, either from repository scanning, or from the webhook.
It is pretty normal to want to define environment variables globally in the pipeline. Those variables may depends on GIT_COMMIT. However, for GIT_COMMIT to be available, `agent none` cannot be used.
The problem caused by inability to use `agent none` globally
If there is an input step in the pipeline and a global agent is used, once the input step is reached, an executor will still be occupied. Eventually, once enough branches reach the input step, all executors will be busy.
With global `agent none` it is possible not to consume an agent when waiting for the input if one follows some additional ceremony of adding `beforeAgent true` to `when` in stages with input steps (and defining a fake always-true condition in `when` if there is no need for a `when` condition otherwise).
However, when one needs GIT_COMMIT in multiple different steps, it forces every step that needs it to check out SCM (which otherwise would be possible to skip) to do so. It also forces stages that could otherwise execute with `agent none` to use an agent (e.g. stages with `input` and `build job` steps only). If also forces a huge amount of duplication of the same environment variable definitions depending on GIT_COMMIT.
None of that would be necessary if GIT_COMMIT (and other SCM variables) were available without checking out SCM.
- Setting global global environment with a scripted procedure - I don't think this will work with stage restarts, and I'm too burned out to try that.
- Using a different set of plugins from what Blue Ocean gives.
Use agent none globally and copy environment variable definitions to every step. Replace every instance of `agent none` with `agent any`.