forked from nodejs/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildpulse.cmd
108 lines (87 loc) · 3.44 KB
/
buildpulse.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
:: CODE TO SEND RESULTS TO BUILDPULSE IF MACHINE IS CONFIGURED
:: IF ANY REQUIRED CONDITION IS NOT MET IT WILL BE SKIPPED
echo "Preparing to send data to BuildPulse."
:: 1.Check organization and repository
echo "Checking organization and repository."
set "REQUIRED_ORGANIZATION=nodejs"
if not "%GITHUB_ORG%"=="%REQUIRED_ORGANIZATION%" (
echo "Organization set to %GITHUB_ORG%, %REQUIRED_ORGANIZATION% required. Cannot send results to BuildPulse."
exit /b 0
)
echo "Organization set to %GITHUB_ORG%."
set "REQUIRED_REPOSITORY=node"
if not "%REPO_NAME%"=="%REQUIRED_REPOSITORY%" (
echo "Repository set to %REPO_NAME%, %REQUIRED_REPOSITORY% required. Cannot send results to BuildPulse."
exit /b 0
)
echo "Repository set to %REPO_NAME%."
:: 2.Check test results
echo "Checking test results."
if "%1"=="" (
echo "No results provided to send to BuildPulse."
exit /b 0
)
if not exist %1 (
echo "No results found in %1 to send to BuildPulse."
exit /b 0
)
echo "Results found in %1."
:: 3.Check required environment variables
echo "Checking required environment variables."
if not defined BUILDPULSE_ACCESS_KEY_ID (
echo "BUILDPULSE_ACCESS_KEY_ID not set. Cannot send results to BuildPulse."
exit /b 0
)
echo "BUILDPULSE_ACCESS_KEY_ID is set."
if not defined BUILDPULSE_SECRET_ACCESS_KEY (
echo "BUILDPULSE_SECRET_ACCESS_KEY not set. Cannot send results to BuildPulse."
exit /b 0
)
echo "BUILDPULSE_SECRET_ACCESS_KEY is set."
if not defined BUILDPULSE_ACCOUNT_ID (
echo "BUILDPULSE_ACCOUNT_ID not set. Cannot send results to BuildPulse."
exit /b 0
)
echo "BUILDPULSE_ACCOUNT_ID is set."
if not defined BUILDPULSE_REPOSITORY_ID (
echo "BUILDPULSE_REPOSITORY_ID not set. Cannot send results to BuildPulse."
exit /b 0
)
echo "BUILDPULSE_REPOSITORY_ID is set."
:: 4.Check test-reporter tool
echo "Checking test-reporter tool."
set "TEST_REPORTER_PATH=C:\test-reporter-windows-amd64.exe"
if not exist %TEST_REPORTER_PATH% (
echo "Cannot find test-reporter tool in %TEST_REPORTER_PATH%. Cannot send results to BuildPulse."
exit /b 0
)
echo "Test-reporter tool found in %TEST_REPORTER_PATH%."
:: 5.Set test-reporter tool required environment variables
echo "Setting test-reporter tool required environment variables."
set "GIT_BRANCH=%GIT_REMOTE_REF%"
:: GIT_COMMIT is already set by Jenkins
:: BUILD_URL is already set by Jenkins
set "ORGANIZATION_NAME=%GITHUB_ORG%"
set "REPOSITORY_NAME=%REPO_NAME%"
echo "GIT_BRANCH set to %GIT_BRANCH%."
echo "GIT_COMMIT set to %GIT_COMMIT%."
echo "BUILD_URL set to %BUILD_URL%."
echo "ORGANIZATION_NAME set to %ORGANIZATION_NAME%."
echo "REPOSITORY_NAME set to %REPOSITORY_NAME%."
:: GIT_URL is required for the test-reporter tool
:: We can hardcode it since we enforce nodejs/node
if "%GIT_URL%"=="" set "GIT_URL=https://github.com/%ORGANIZATION_NAME%/%REPOSITORY_NAME%"
echo "GIT_URL set to %GIT_URL%."
:: 6.Send results to BuildPulse
echo "Sending data to BuildPulse."
:: Add available tags for easier navigation in BuildPulse
set "TAGS=%NODE_NAME% %nodes% v%NODEJS_MAJOR_VERSION%"
if defined NODEJS_VERSION (
set "TAGS=%TAGS% v%NODEJS_VERSION%"
)
:: Edit BUILD_URL to enable better grouping in BuildPulse
set "BUILD_URL_BACKUP=%BUILD_URL%"
for /f "usebackq delims=" %%i in (`powershell -File "%~dp0modify-build-url.ps1" -BUILD_URL "%BUILD_URL%"`) do set "BUILD_URL=%%i"
%TEST_REPORTER_PATH% submit %1 --account-id %BUILDPULSE_ACCOUNT_ID% --repository-id %BUILDPULSE_REPOSITORY_ID% --tags "%TAGS%"
set "BUILD_URL=%BUILD_URL_BACKUP%"
exit /b 0