@@ -11,41 +11,59 @@ export function detect(envs: ProviderEnvs): boolean {
1111 return Boolean ( envs ?. CI ) && Boolean ( envs ?. BITRISE_IO ) ;
1212}
1313
14- function _getBuild ( inputs : ProviderUtilInputs ) : ProviderServiceParams [ "build" ] {
14+ function _getBuild (
15+ inputs : ProviderUtilInputs ,
16+ output : Output ,
17+ ) : ProviderServiceParams [ "build" ] {
1518 const { args, envs } = inputs ;
1619 if ( args ?. build && args . build !== "" ) {
1720 return args . build ;
1821 }
19- return envs ?. BITRISE_BUILD_NUMBER ?? null ;
22+ const build = envs ?. BITRISE_BUILD_NUMBER ?? null ;
23+ debug ( `Using build: ${ build } ` , { enabled : output . debug } ) ;
24+ return build ;
2025}
2126
2227function _getBuildURL (
2328 inputs : ProviderUtilInputs ,
29+ output : Output ,
2430) : ProviderServiceParams [ "buildURL" ] {
2531 const { envs } = inputs ;
26- return envs ?. BITRISE_BUILD_URL ?? null ;
32+ const buildURL = envs ?. BITRISE_BUILD_URL ?? null ;
33+ debug ( `Using buildURL: ${ buildURL } ` , { enabled : output . debug } ) ;
34+ return buildURL ;
2735}
2836
2937function _getBranch (
3038 inputs : ProviderUtilInputs ,
39+ output : Output ,
3140) : ProviderServiceParams [ "branch" ] {
3241 const { args, envs } = inputs ;
3342 if ( args ?. branch && args . branch !== "" ) {
3443 return args . branch ;
3544 }
36- return envs ?. BITRISE_GIT_BRANCH ?? null ;
45+ const branch = envs ?. BITRISE_GIT_BRANCH ?? null ;
46+ debug ( `Using branch: ${ branch } ` , { enabled : output . debug } ) ;
47+ return branch ;
3748}
3849
39- function _getJob ( ) : ProviderServiceParams [ "job" ] {
50+ function _getJob ( output : Output ) : ProviderServiceParams [ "job" ] {
51+ debug ( `Using job: ${ null } ` , { enabled : output . debug } ) ;
4052 return null ;
4153}
4254
43- function _getPR ( inputs : ProviderUtilInputs ) : ProviderServiceParams [ "pr" ] {
55+ function _getPR (
56+ inputs : ProviderUtilInputs ,
57+ output : Output ,
58+ ) : ProviderServiceParams [ "pr" ] {
4459 const { args, envs } = inputs ;
4560 if ( args ?. pr && args . pr !== "" ) {
61+ debug ( `Using pr: ${ args . pr } ` , { enabled : output . debug } ) ;
4662 return args . pr ;
4763 }
48- return envs ?. BITRISE_PULL_REQUEST ?? null ;
64+ const pr = envs ?. BITRISE_PULL_REQUEST ?? null ;
65+ debug ( `Using pr: ${ pr } ` , { enabled : output . debug } ) ;
66+ return pr ;
4967}
5068
5169function _getService ( ) : ProviderServiceParams [ "service" ] {
@@ -73,12 +91,18 @@ function _getSHA(
7391 return envs ?. GIT_CLONE_COMMIT_HASH ?? null ;
7492}
7593
76- function _getSlug ( inputs : ProviderUtilInputs ) : ProviderServiceParams [ "slug" ] {
94+ function _getSlug (
95+ inputs : ProviderUtilInputs ,
96+ output : Output ,
97+ ) : ProviderServiceParams [ "slug" ] {
7798 const { args } = inputs ;
7899 if ( args ?. slug && args . slug !== "" ) {
100+ debug ( `Using slug: ${ args . slug } ` , { enabled : output . debug } ) ;
79101 return args . slug ;
80102 }
81- return parseSlugFromRemoteAddr ( "" ) ?? null ;
103+ const slug = parseSlugFromRemoteAddr ( "" ) ?? null ;
104+ debug ( `Using slug: ${ slug } ` , { enabled : output . debug } ) ;
105+ return slug ;
82106}
83107
84108// eslint-disable-next-line @typescript-eslint/require-await
@@ -87,14 +111,14 @@ export async function getServiceParams(
87111 output : Output ,
88112) : Promise < ProviderServiceParams > {
89113 return {
90- branch : _getBranch ( inputs ) ,
91- build : _getBuild ( inputs ) ,
92- buildURL : _getBuildURL ( inputs ) ,
114+ branch : _getBranch ( inputs , output ) ,
115+ build : _getBuild ( inputs , output ) ,
116+ buildURL : _getBuildURL ( inputs , output ) ,
93117 commit : _getSHA ( inputs , output ) ,
94- job : _getJob ( ) ,
95- pr : _getPR ( inputs ) ,
118+ job : _getJob ( output ) ,
119+ pr : _getPR ( inputs , output ) ,
96120 service : _getService ( ) ,
97- slug : _getSlug ( inputs ) ,
121+ slug : _getSlug ( inputs , output ) ,
98122 } ;
99123}
100124
0 commit comments