function getEndpointDetails(inputFieldName) {
    var errorMessage = "Could not decode the External Tfs endpoint. Please ensure you are running the latest agent";
    if (!tl.getEndpointUrl) {
        throw new Error(errorMessage);
    }
    var externalTfsEndpoint = tl.getInput(inputFieldName);
    if (!externalTfsEndpoint) {
        throw new Error(errorMessage);
    }
    var hostUrl = tl.getEndpointUrl(externalTfsEndpoint, false);
    if (!hostUrl) {
        throw new Error(errorMessage);
    }
    var auth = tl.getEndpointAuthorization(externalTfsEndpoint, false);
    if (auth.scheme != "UsernamePassword" && auth.scheme != "Token") {
        throw new Error("The authorization scheme " + auth.scheme + " is not supported for a External Tfs endpoint.");
    }

    var hostUsername = "******";
    var hostPassword = "";
    if(auth.scheme == "Token") {
        hostPassword = getAuthParameter(auth, 'apitoken');
    }
    else {
        hostUsername = getAuthParameter(auth, 'username');
        hostPassword = getAuthParameter(auth, 'password');
    }
    return {
        "Url": hostUrl,
        "Username": hostUsername,
        "Password": hostPassword
    };
}
function getAuthParameter(endpoint, paramName) {
    var paramValue = null;
    var auth = tl.getEndpointAuthorization(endpoint, false);
    
    if (auth.scheme.toLowerCase().trim() != "usernamepassword") {
        throw new Error("The authorization scheme " + auth.scheme + " is not supported for a bitbucket endpoint. Please use a basic instead.");
    }
    
    var keyName = getCaseInsensitiveKeyMatch(auth['parameters'], paramName);
    paramValue = auth['parameters'][keyName];

    return paramValue;
}
var tl = require('vsts-task-lib/task');
var path = require('path');
var fs = require('fs');
var onError = function (errMsg) {
    tl.error(errMsg);
    tl.exit(1);
};
var serverEndpoint = tl.getInput('serverEndpoint', true);
if (!serverEndpoint) {
    onError('The IBM UrbanCode Deploy Endpoint could not be found');
}
var serverEndpointUrl = tl.getEndpointUrl(serverEndpoint, false);
if (!serverEndpointUrl) {
    onError('The IBM UrbanCode Deploy Endpoint URL could not be found');
}
var serverEndpointAuth = tl.getEndpointAuthorization(serverEndpoint, false);
var username = serverEndpointAuth['parameters']['username'];
var password = serverEndpointAuth['parameters']['password'];
var token = null;
// if there is no username, then the password field is actually a token.
if (username == null || username.length == 0) {
    tl.debug('username not specified in serverEndpoint, using password as token');
    token = password;
}
var workingDir = tl.getInput('workingDirectory', true);
var udClientPath; // loaded below
var udClientLocation = tl.getInput('udClientLocation');
if (udClientLocation != tl.getVariable('build.sourcesDirectory')) {
    //custom tool location for udclient was specified
    tl.debug('udclient location specified explicitly by task: ' + udClientLocation);
    udClientPath = udClientLocation;