DataDog / datadog-ci

Use Datadog from your CI.
https://datadoghq.com
Apache License 2.0
119 stars 51 forks source link

Accept Custom Repository URLs with Additional Repository Provider Flag #689

Open hsantanabt opened 1 year ago

hsantanabt commented 1 year ago

Is your feature request related to a problem? Please describe: Not a problem.

Describe the solution you'd like: The --repository-url flag should accept Custom GitLab Repository URLs. An URL formatted as: e.g. https://git.company.dev/repo-group/ui -> https://git.company.dev/repo-group/ui/-/blob/develop/Dockerfile#L1. There can be an additional flag to specify the provider to use: --repository-provider to be one of the already supported options.

Describe alternatives you've considered: There are currently no alternatives.

Additional context: This was tested with the latest version of the CI and this sample script:

#!/usr/bin/env bash
set -e

ssm-starter --ssm-name ui
. ./environ && rm ./environ
confd -onetime -backend env

echo "setting release tag"
export BT_RELEASE=$(</static/revision.txt)

npm install @datadog/datadog-ci

echo "uploading source maps"
./node_modules/.bin/datadog-ci sourcemaps upload "/app/jsmaps" \
  --project-path="/app" \
  --service="$DOMAIN_NAME" \
  --release-version="$BT_RELEASE" \
  --minified-path-prefix="/" \
  --repository-url="https://git.company.dev/repo-group/u" \
  --disable-git
fracampit commented 2 months ago

This is currently preventing us from linking source code to our services on DataDog.

We are trying to setup repository metadata upload between a self-managed GitLab instance and DataDog.

The instructions on DataDog suggest running this command: git-metadata

It seems to run fine:

$ export DATADOG_API_KEY=$DD_API_KEY
$ export DATADOG_SITE='datadoghq.eu'
$ datadog-ci git-metadata upload
Uploading list of tracked files...
(node:31) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Reporting commit cd6742a4f390f6277eb0182249ea9c2ed1ac7521 from repository https://git.tools.dev.assaabloyglobalsolutions.net/traka/software/traka-internal-development-projects/traka-technology-portal/tech-portal-web-front-end.git.
88 tracked file paths will be reported.
Successfully uploaded tracked files in 0.359 seconds.
Syncing GitDB...
[unshallow] Git repository is a shallow clone, unshallowing it...
[unshallow] Running git fetch --shallow-since="1 month ago" --update-shallow --filter=blob:none --recurse-submodules=no $(git config --default origin --get clone.defaultRemoteName) $(git rev-parse HEAD)
[unshallow] Fetch completed.
fatal: unable to rename temporary file to '/tmp/dd-packfiles-lEEbFI/551-bc0c52a0efbfa81c224d0dbeb4ea86ceaf377d56.pack': Cross-device link
Failed generation of packfiles in tmpdir: Error: Command failed: git pack-objects --compression=9 --max-pack-size=3m /tmp/dd-packfiles-lEEbFI/551
fatal: unable to rename temporary file to '/tmp/dd-packfiles-lEEbFI/551-bc0c52a0efbfa81c224d0dbeb4ea86ceaf377d56.pack': Cross-device link
Generating them in /builds/traka/software/traka-internal-development-projects/traka-technology-portal/tech-portal-web-front-end instead
Successfully synced git DB in 1.082 seconds.
✅ Uploaded in 1.482 seconds.

However, I get this error in DataDog:

We couldn't automatically detect the Source Code Management provider (GitHub, Gitlab...) for this repository. Please reach out to support.

Looking at this guide: git-metadata, it looks like it won't be able to determine the provider due to the GitLab URL missing "gitlab" (the URL for my self-managed GitLab instance is git.tools.dev.assaabloyglobalsolutions.net)