Skip to content

Commit 807c189

Browse files
authored
fix: teamcity env var extraction (#5271)
Adds a test for TeamCity and updates the env vars we read to match the CI App spec.
1 parent c45a5f1 commit 807c189

File tree

2 files changed

+80
-10
lines changed

2 files changed

+80
-10
lines changed

ddtrace/ext/ci.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -432,17 +432,9 @@ def extract_teamcity(env):
432432
# type: (MutableMapping[str, str]) -> Dict[str, Optional[str]]
433433
"""Extract CI tags from Teamcity environ."""
434434
return {
435-
git.COMMIT_SHA: env.get("BUILD_VCS_NUMBER"),
436-
git.REPOSITORY_URL: env.get("BUILD_VCS_URL"),
437-
PIPELINE_ID: env.get("BUILD_ID"),
438-
PIPELINE_NUMBER: env.get("BUILD_NUMBER"),
439-
PIPELINE_URL: (
440-
"{0}/viewLog.html?buildId={1}".format(env.get("SERVER_URL"), env.get("BUILD_ID"))
441-
if env.get("SERVER_URL") and env.get("BUILD_ID")
442-
else None
443-
),
435+
JOB_URL: env.get("BUILD_URL"),
436+
JOB_NAME: env.get("TEAMCITY_BUILDCONF_NAME"),
444437
PROVIDER_NAME: "teamcity",
445-
WORKSPACE_PATH: env.get("BUILD_CHECKOUTDIR"),
446438
}
447439

448440

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[
2+
[
3+
{
4+
"BUILD_URL": "the-build-url",
5+
"TEAMCITY_BUILDCONF_NAME": "Test 1",
6+
"TEAMCITY_VERSION": "2022.10 (build 116751)"
7+
},
8+
{
9+
"ci.job.name": "Test 1",
10+
"ci.job.url": "the-build-url",
11+
"ci.provider.name": "teamcity"
12+
}
13+
],
14+
[
15+
{
16+
"BUILD_URL": "the-build-url",
17+
"DD_GIT_BRANCH": "user-supplied-branch",
18+
"DD_GIT_COMMIT_AUTHOR_DATE": "usersupplied-authordate",
19+
"DD_GIT_COMMIT_AUTHOR_EMAIL": "usersupplied-authoremail",
20+
"DD_GIT_COMMIT_AUTHOR_NAME": "usersupplied-authorname",
21+
"DD_GIT_COMMIT_COMMITTER_DATE": "usersupplied-comitterdate",
22+
"DD_GIT_COMMIT_COMMITTER_EMAIL": "usersupplied-comitteremail",
23+
"DD_GIT_COMMIT_COMMITTER_NAME": "usersupplied-comittername",
24+
"DD_GIT_COMMIT_MESSAGE": "usersupplied-message",
25+
"DD_GIT_COMMIT_SHA": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
26+
"DD_GIT_REPOSITORY_URL": "[email protected]:DataDog/userrepo.git",
27+
"TEAMCITY_BUILDCONF_NAME": "Test 1",
28+
"TEAMCITY_VERSION": "2022.10 (build 116751)"
29+
},
30+
{
31+
"ci.job.name": "Test 1",
32+
"ci.job.url": "the-build-url",
33+
"ci.provider.name": "teamcity",
34+
"git.branch": "user-supplied-branch",
35+
"git.commit.author.date": "usersupplied-authordate",
36+
"git.commit.author.email": "usersupplied-authoremail",
37+
"git.commit.author.name": "usersupplied-authorname",
38+
"git.commit.committer.date": "usersupplied-comitterdate",
39+
"git.commit.committer.email": "usersupplied-comitteremail",
40+
"git.commit.committer.name": "usersupplied-comittername",
41+
"git.commit.message": "usersupplied-message",
42+
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
43+
"git.repository_url": "[email protected]:DataDog/userrepo.git"
44+
}
45+
],
46+
[
47+
{
48+
"BUILD_URL": "the-build-url",
49+
"DD_GIT_COMMIT_AUTHOR_DATE": "usersupplied-authordate",
50+
"DD_GIT_COMMIT_AUTHOR_EMAIL": "usersupplied-authoremail",
51+
"DD_GIT_COMMIT_AUTHOR_NAME": "usersupplied-authorname",
52+
"DD_GIT_COMMIT_COMMITTER_DATE": "usersupplied-comitterdate",
53+
"DD_GIT_COMMIT_COMMITTER_EMAIL": "usersupplied-comitteremail",
54+
"DD_GIT_COMMIT_COMMITTER_NAME": "usersupplied-comittername",
55+
"DD_GIT_COMMIT_MESSAGE": "usersupplied-message",
56+
"DD_GIT_COMMIT_SHA": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
57+
"DD_GIT_REPOSITORY_URL": "[email protected]:DataDog/userrepo.git",
58+
"DD_GIT_TAG": "0.0.2",
59+
"TEAMCITY_BUILDCONF_NAME": "Test 1",
60+
"TEAMCITY_VERSION": "2022.10 (build 116751)"
61+
},
62+
{
63+
"ci.job.name": "Test 1",
64+
"ci.job.url": "the-build-url",
65+
"ci.provider.name": "teamcity",
66+
"git.commit.author.date": "usersupplied-authordate",
67+
"git.commit.author.email": "usersupplied-authoremail",
68+
"git.commit.author.name": "usersupplied-authorname",
69+
"git.commit.committer.date": "usersupplied-comitterdate",
70+
"git.commit.committer.email": "usersupplied-comitteremail",
71+
"git.commit.committer.name": "usersupplied-comittername",
72+
"git.commit.message": "usersupplied-message",
73+
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
74+
"git.repository_url": "[email protected]:DataDog/userrepo.git",
75+
"git.tag": "0.0.2"
76+
}
77+
]
78+
]

0 commit comments

Comments
 (0)