Function: SSH Command Get File

by Simon Sparks · 24 March 2026

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

public getFile(strHostFQDN: string, strUsername: string, strPassword: string, strRemoteFilePath: string, strLocalFileName: String, intPort: number = 22): boolean {
    try {
        let strLocalFilePath: string = `/var/run/vco/${strLocalFileName}-${(new Date()).getTime()}.txt`;

        let objSSHCommand: SSHCommand = new SSHCommand(strHostFQDN, strUsername, strPassword, intPort);

        let intExitCode: number = objSSHCommand.getFile(strRemoteFilePath, strLocalFilePath);

        if (intExitCode !== 0) {
            this.objLogger.info(`Error while getting content of ${strRemoteFilePath} to remote location "${strLocalFilePath}". Exit code: ${intExitCode}.`);
        }

        return true;
    } catch (objException) {
        return false;
    }
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like