I was looking for any documentation anywhere that said how to get the attempt number of a job in a build pipeline. You can re-run jobs using the GitHub UI for PRs and hitting 'Re-run' on a failed job, for example. I only discovered System.JobAttempt after displaying all the environment variables in a build pipeline using PowerShell. Please add documentation for this predefined environment variable.
Note: There is Release.AttemptNumber, but that value only exists for release pipelines.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Also, there is many other variables currently not listed on the page, such as Job.JobId. I only noticed this because an agentless "Invoke REST" task has it in its headers by default, and was wondering if there was an equivalent for the whole phase as well (so I can ignore certain tasks when poking _apis/build/builds/{buildId}/timeline to get results of previous phases).
While it's nice to have a script to dump environment variables for this, it isn't always possible and/or practical to use one of these; and a complete documentation (or at least reference somewhere in source) would help a lot.
Other examples that stand out include:
It surprises me these aren't in the documentation here, considering you can find references to them in other pages of the documentation.
Most helpful comment
Also, there is many other variables currently not listed on the page, such as
Job.JobId. I only noticed this because an agentless "Invoke REST" task has it in its headers by default, and was wondering if there was an equivalent for the whole phase as well (so I can ignore certain tasks when poking_apis/build/builds/{buildId}/timelineto get results of previous phases).While it's nice to have a script to dump environment variables for this, it isn't always possible and/or practical to use one of these; and a complete documentation (or at least reference somewhere in source) would help a lot.