@@ -66,7 +66,7 @@ async function main(): Promise<void> {
66
66
67
67
const tokenAuthInfo = serviceConnection as TokenServiceConnection ;
68
68
tl . debug ( `Detected token credentials for '${ serviceConnection . packageSource . uri } '` ) ;
69
- tl . setVariable ( "CARGO_REGISTRY_TOKEN" , tokenAuthInfo . token ) ;
69
+ setSecretEnvVariable ( "CARGO_REGISTRY_TOKEN" , tokenAuthInfo . token ) ;
70
70
tl . setVariable ( "CARGO_REGISTRY_CREDENTIAL_PROVIDER" , "cargo:token" ) ;
71
71
break ;
72
72
default :
@@ -87,14 +87,14 @@ async function main(): Promise<void> {
87
87
currentRegistry = registry ;
88
88
tl . debug ( `Detected username/password or PAT credentials for '${ serviceConnection . packageSource . uri } '` ) ;
89
89
tl . debug ( tl . loc ( 'AddingAuthExternalRegistry' , registry , tokenName ) ) ;
90
- tl . setVariable ( tokenName , `Basic ${ base64 . encode ( utf8 . encode ( `${ usernamePasswordAuthInfo . username } :${ usernamePasswordAuthInfo . password } ` ) ) } ` ) ;
90
+ setSecretEnvVariable ( tokenName , `Basic ${ base64 . encode ( utf8 . encode ( `${ usernamePasswordAuthInfo . username } :${ usernamePasswordAuthInfo . password } ` ) ) } ` ) ;
91
91
tl . setVariable ( credProviderName , "cargo:token" ) ;
92
92
}
93
93
}
94
94
// Default to internal registry if no token has been set yet
95
95
if ( ! currentRegistry ) {
96
96
tl . debug ( tl . loc ( 'AddingAuthRegistry' , registry , tokenName ) ) ;
97
- tl . setVariable ( tokenName , localAccesstoken ) ;
97
+ setSecretEnvVariable ( tokenName , localAccesstoken ) ;
98
98
tl . setVariable ( credProviderName , "cargo:token" ) ;
99
99
}
100
100
}
@@ -108,4 +108,13 @@ async function main(): Promise<void> {
108
108
}
109
109
}
110
110
111
+ // Register the value as a secret to the logger before setting the value in an enviornment variable.
112
+ // Use when needed to set a specific enviornment variable whose value is a secret. We cannot use
113
+ // setVariable(_, , isSecret=true) because it adds SECRET_ as a prefix to the env variable.
114
+ // TODO: Move to a common location
115
+ function setSecretEnvVariable ( variableName : string , value : string ) {
116
+ tl . setSecret ( value ) ;
117
+ tl . setVariable ( variableName , value ) ;
118
+ }
119
+
111
120
main ( ) ;
0 commit comments