watson / ci-info

Get details about the current Continuous Integration environment
MIT License
319 stars 49 forks source link

Add Support for Azure DevOps in isCI #109

Closed egg-r closed 11 months ago

egg-r commented 1 year ago

Details:

Environment variables

Environment variables example ``` // Add a list of actual environment variables available to the build here // Please keep the blank line above and below the code block // WARNING: Be careful not to include any private or otherwise sensitive information ``` BUILD_BUILDID=123456 BUILD_ARTIFACTSTAGINGDIRECTORY=/agent/_work/1/a

Additional context Add any other context about the problem here.

The mentioned Azure DevOps predefined variables get reformatted to the mentioned syntax for available pipeline environment variables.

egg-r commented 1 year ago

For more context, this request was sparked by pnpm's use of the CI check for frozen-lock feature.

Documentation: https://pnpm.io/cli/install#--frozen-lockfile

It doesn't look like Azure DevOps is supported within the "isCI" check and looking for CI environment vars.

https://github.com/watson/ci-info/blob/master/index.js

sagiegurari commented 1 year ago

I don't know azure devops, but i think azure pipelines is supported and if i'm not wrong (probably wrong), its part of azure devops

https://github.com/watson/ci-info/blob/20fae89d2bdeb0e5dd70e6a9e8d2647764e6ff04/vendors.json#L19

jrdodds commented 11 months ago

The major components of Azure DevOps are Azure Artifacts, Azure Boards, Azure Pipelines, Azure Repos, and Azure Test Plans. Azure Pipelines is specifically the build/release pipeline support. Often Azure Pipelines will just be referred to as Azure DevOps and the context informs that it is Azure Pipelines that is being discussed.

All of the following are current or prior names for Azure DevOps:

The vendors.json entry for Azure Pipelines covers all of these.

The correct way to detect Azure Pipelines is to check if the TF_BUILD environment variable is defined. If defined it should have a value of true.

In #23 SYSTEM_TEAMFOUNDATIONCOLLECTIONURI was used because TF_BUILD was used for Team Foundation Server but the Team Foundation Server entry has since been removed.

SYSTEM_PULLREQUEST_PULLREQUESTID provides the actual PR ID. To just know that the build is for a PR, check that BUILD_REASON has the value PullRequest.

See PR #116.

[^1]: On-premise versions are named Server and cloud versions are named Services.

sibiraj-s commented 11 months ago

Thanks @jrdodds for the update

sibiraj-s commented 11 months ago

Merged #116 and published in v3.9.0. Should be fixed now.