@@ -12,39 +12,61 @@ export function detect(envs: ProviderEnvs): boolean {
1212 return Boolean ( envs ?. CI ) && Boolean ( envs ?. BITBUCKET_BUILD_NUMBER ) ;
1313}
1414
15- function _getBuild ( inputs : ProviderUtilInputs ) : ProviderServiceParams [ "build" ] {
15+ function _getBuild (
16+ inputs : ProviderUtilInputs ,
17+ output : Output ,
18+ ) : ProviderServiceParams [ "build" ] {
1619 const { args, envs } = inputs ;
1720 if ( args ?. build && args . build !== "" ) {
21+ debug ( `Using build: ${ args . build } ` , { enabled : output . debug } ) ;
1822 return args . build ;
1923 }
20- return envs ?. BITBUCKET_BUILD_NUMBER ?? null ;
24+ const build = envs ?. BITBUCKET_BUILD_NUMBER ?? null ;
25+ debug ( `Using build: ${ build } ` , { enabled : output . debug } ) ;
26+ return build ;
2127}
2228
23- function _getBuildURL ( ) : ProviderServiceParams [ "buildURL" ] {
29+ function _getBuildURL ( output : Output ) : ProviderServiceParams [ "buildURL" ] {
2430 // TODO: https://github.com/codecov/uploader/issues/267
31+ debug ( `Using buildURL: ${ null } ` , { enabled : output . debug } ) ;
2532 return null ;
2633}
2734
2835function _getBranch (
2936 inputs : ProviderUtilInputs ,
37+ output : Output ,
3038) : ProviderServiceParams [ "branch" ] {
3139 const { args, envs } = inputs ;
3240 if ( args ?. branch && args ?. branch !== "" ) {
41+ debug ( `Using branch: ${ args ?. branch } ` , { enabled : output . debug } ) ;
3342 return args ?. branch ;
3443 }
35- return envs ?. BITBUCKET_BRANCH ?? null ;
44+ const branch = envs ?. BITBUCKET_BRANCH ?? null ;
45+ debug ( `Using branch: ${ branch } ` , { enabled : output . debug } ) ;
46+ return branch ;
3647}
3748
38- function _getJob ( envs : ProviderEnvs ) : ProviderServiceParams [ "job" ] {
39- return envs ?. BITBUCKET_BUILD_NUMBER ?? null ;
49+ function _getJob (
50+ envs : ProviderEnvs ,
51+ output : Output ,
52+ ) : ProviderServiceParams [ "job" ] {
53+ const job = envs ?. BITBUCKET_BUILD_NUMBER ?? null ;
54+ debug ( `Using job: ${ job } ` , { enabled : output . debug } ) ;
55+ return job ;
4056}
4157
42- function _getPR ( inputs : ProviderUtilInputs ) : ProviderServiceParams [ "pr" ] {
58+ function _getPR (
59+ inputs : ProviderUtilInputs ,
60+ output : Output ,
61+ ) : ProviderServiceParams [ "pr" ] {
4362 const { args, envs } = inputs ;
4463 if ( args ?. pr && args . pr !== "" ) {
64+ debug ( `Using PR: ${ args . pr } ` , { enabled : output . debug } ) ;
4565 return args . pr ;
4666 }
47- return envs ?. BITBUCKET_PR_ID ?? null ;
67+ const pr = envs ?. BITBUCKET_PR_ID ?? null ;
68+ debug ( `Using PR: ${ pr } ` , { enabled : output . debug } ) ;
69+ return pr ;
4870}
4971
5072function _getService ( ) : ProviderServiceParams [ "service" ] {
@@ -74,12 +96,18 @@ function _getSHA(
7496 return commit ?? null ;
7597}
7698
77- function _getSlug ( inputs : ProviderUtilInputs ) : ProviderServiceParams [ "slug" ] {
99+ function _getSlug (
100+ inputs : ProviderUtilInputs ,
101+ output : Output ,
102+ ) : ProviderServiceParams [ "slug" ] {
78103 const { args, envs } = inputs ;
79104 if ( args ?. slug && args . slug !== "" ) {
105+ debug ( `Using slug: ${ args . slug } ` , { enabled : output . debug } ) ;
80106 return args . slug ;
81107 }
82- return envs ?. BITBUCKET_REPO_FULL_NAME ?? null ;
108+ const slug = envs ?. BITBUCKET_REPO_FULL_NAME ?? null ;
109+ debug ( `Using slug: ${ slug } ` , { enabled : output . debug } ) ;
110+ return slug ;
83111}
84112
85113// eslint-disable-next-line @typescript-eslint/require-await
@@ -88,14 +116,14 @@ export async function getServiceParams(
88116 output : Output ,
89117) : Promise < ProviderServiceParams > {
90118 return {
91- branch : _getBranch ( inputs ) ,
92- build : _getBuild ( inputs ) ,
93- buildURL : _getBuildURL ( ) ,
119+ branch : _getBranch ( inputs , output ) ,
120+ build : _getBuild ( inputs , output ) ,
121+ buildURL : _getBuildURL ( output ) ,
94122 commit : _getSHA ( inputs , output ) ,
95- job : _getJob ( inputs . envs ) ,
96- pr : _getPR ( inputs ) ,
123+ job : _getJob ( inputs . envs , output ) ,
124+ pr : _getPR ( inputs , output ) ,
97125 service : _getService ( ) ,
98- slug : _getSlug ( inputs ) ,
126+ slug : _getSlug ( inputs , output ) ,
99127 } ;
100128}
101129
0 commit comments