To use this function add it to the class library file named PluginSSHService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: PluginSSHService.ts
Description: Orchestrator Function to Get a File via SSH
Public Function: getFile
publicgetFile(strHostFQDN:string,strUsername:string,strPassword:string,strRemoteFilePath:string,strLocalFileName:String,intPort:number=22):boolean{
try{
letstrLocalFilePath:string=`/var/run/vco/${strLocalFileName}-${(newDate()).getTime()}.txt`;
letobjSSHCommand:SSHCommand=newSSHCommand(strHostFQDN,strUsername,strPassword,intPort);
letintExitCode:number=objSSHCommand.getFile(strRemoteFilePath,strLocalFilePath);
if (intExitCode!==0){
this.objLogger.info(`Error while getting content of${strRemoteFilePath} to remote location "${strLocalFilePath}". Exit code:${intExitCode}.`);
}
returntrue;
}catch (objException){
returnfalse;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
