Skip to content

feat(sdk): detect PR context on GitHub Enterprise, self-managed GitLab and Azure DevOps Server (#241) - #242

Merged
xping-admin merged 2 commits into
mainfrom
feat/241-pr-context-any-host
Oct 6, 2026
Merged

xping-admin merged 2 commits into
mainfrom
feat/241-pr-context-any-host

Conversation

@xping-admin

Copy link
Copy Markdown
Collaborator

Closes #241 (SDK side). The Cloud side is a separate dashboard PR that bumps to the package this publishes.

What changes for users

PR builds on GitHub Enterprise Server, GHE.com, self-managed GitLab and Azure DevOps Server now get PR context instead of being filed as plain branch runs.

How

  • PullRequestContext.ServerUrl: the server the repository lives on, normalized to scheme, lowercase host, non-default port and path, with no trailing /. The same repo gets the same value from every detector.
  • GitHub Actions: GITHUB_SERVER_URL. A missing value still warns.
  • GitLab: CI_SERVER_URL replaces CI_SERVER_HOST, so the port and relative root are kept.
  • Azure Pipelines:
    • GitHub / GitHubEnterprise providers: the server comes from BUILD_REPOSITORY_URI.
    • TfsGit: Azure DevOps Server collections are accepted, with owner {collection}/{project}.
    • dev.azure.com and *.visualstudio.com both map to https://dev.azure.com.
  • Jenkins: the platform is read from the CHANGE_URL path shape on any host:
    • /pull/n is GitHub, /-/merge_requests/n is GitLab, /_git/r/pullrequest/n is Azure Repos.
    • Gitea pulls and Bitbucket pull-requests still return null.
    • Known limit: a GitLab relative URL root lands in the owner.
  • CI.ServerUrl is now set on GitHub Actions, GitLab, Azure Pipelines and Bitbucket, so CI.Repository is no longer ambiguous across servers (CI.Repository has no host, so GitHub Enterprise runs can be matched to github.com repos #240).
  • Docs: configuration-reference.md and ci-cd-setup.md. They now say PR comments are github.com-only; that's tracked on the Cloud side.

Tests

  • The tests that asserted the GHES / self-managed skips now assert success and the expected ServerUrl.
  • New tests cover the normalizer, the Azure DevOps Server and GitHubEnterprise paths, self-hosted Jenkins CHANGE_URLs, and CI.ServerUrl per platform.
  • The Jenkins parity tests now also compare ServerUrl.
  • dotnet build -c Release is clean, dotnet format --verify-no-changes passes, and all six test projects pass.

🤖 Generated with Claude Code

…b and Azure DevOps Server (#241)

PR context now records the server the repository lives on (PullRequestContext.ServerUrl), so the
github.com / gitlab.com / Azure DevOps Services-only gates are gone:

- GitHub Actions: server from GITHUB_SERVER_URL (github.com, GHE.com, GHES).
- GitLab: server from CI_SERVER_URL (port and relative root included) instead of CI_SERVER_HOST.
- Azure Pipelines: GitHub and GitHubEnterprise providers take the server from BUILD_REPOSITORY_URI;
  TfsGit accepts Azure DevOps Server collections (owner {collection}/{project}). Both Azure DevOps
  Services URL forms normalize to https://dev.azure.com.
- Jenkins: the platform is read from the CHANGE_URL path shape on any host.

CI metadata gains CI.ServerUrl (GitHub, GitLab, Azure Pipelines, Bitbucket), normalized the same
way, so CI.Repository is no longer ambiguous across servers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.97959% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...vices/Environment/Internals/EnvironmentDetector.cs 92.30% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
...Sdk.Core/Models/PullRequests/PullRequestContext.cs 100.00% <100.00%> (ø)
...equest/Internals/AzureDevOpsPullRequestDetector.cs 100.00% <100.00%> (ø)
...PullRequest/Internals/GitHubPullRequestDetector.cs 99.00% <100.00%> (-0.04%) ⬇️
...PullRequest/Internals/GitLabPullRequestDetector.cs 100.00% <100.00%> (ø)
...ullRequest/Internals/JenkinsPullRequestDetector.cs 100.00% <100.00%> (ø)
...es/PullRequest/Internals/PullRequestEnvironment.cs 100.00% <100.00%> (ø)
...vices/Environment/Internals/EnvironmentDetector.cs 72.75% <92.30%> (+1.69%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Review follow-ups on #242:
- Azure Pipelines: CI.ServerUrl for Azure Repos comes from SYSTEM_COLLECTIONURI, like the PR
  context, so legacy visualstudio.com organizations report https://dev.azure.com and Azure DevOps
  Server keeps its virtual directory (/tfs).
- Bitbucket: CI.ServerUrl is no longer recorded. Pipelines only runs on bitbucket.org, and its
  origin variable is http://, which disagreed with https identities.
- Jenkins: a CHANGE_URL with a "_git" segment that isn't Azure Repos (a GitLab project named
  _git) falls through to the GitLab and GitHub parsers instead of returning null.
- Jenkins: document that a GitLab relative URL root makes Jenkins and GitLab CI report different
  identities.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@xping-admin
xping-admin merged commit 7544cf2 into main Oct 6, 2026
2 checks passed
@xping-admin
xping-admin deleted the feat/241-pr-context-any-host branch October 6, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support PR context on GitHub Enterprise and self-managed GitLab

1 participant