How to use the azure-pipelines-task-lib/task.error function in azure-pipelines-task-lib

To help you get started, we’ve selected a few azure-pipelines-task-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / azure-pipelines-tasks / Tasks / DotNetCoreInstallerV1 / versionfetcher.ts View on Github external
let matchedVersionInfo = utils.getMatchingVersionFromList(versionInfoList, versionSpec, includePreviewVersions);
                    if (!matchedVersionInfo) {
                        console.log(tl.loc("MatchingVersionNotFound", packageType, versionSpec));
                        return null;
                    }

                    console.log(tl.loc("MatchingVersionForUserInputVersion", matchedVersionInfo.getVersion(), channelInformation.channelVersion, versionSpec))
                    return matchedVersionInfo;
                })
                .catch((ex) => {
                    tl.error(tl.loc("ErrorWhileGettingVersionFromChannel", versionSpec, channelInformation.channelVersion, JSON.stringify(ex)));
                    return null;
                });
        }
        else {
            tl.error(tl.loc("UrlForReleaseChannelNotFound", channelInformation.channelVersion));
        }
    }
github microsoft / azure-pipelines-tasks / Tasks / KubernetesManifestV0 / src / utils / DeploymentHelper.ts View on Github external
}
    podStatus = getPodStatus(kubectl, podName);
    switch (podStatus.phase) {
        case 'Succeeded':
        case 'Running':
            if (isPodReady(podStatus)) {
                console.log(`pod/${podName} is successfully rolled out`);
            }
            break;
        case 'Pending':
            if (!isPodReady(podStatus)) {
                tl.warning(`pod/${podName} rollout status check timedout`);
            }
            break;
        case 'Failed':
            tl.error(`pod/${podName} rollout failed`);
            break;
        default:
            tl.warning(`pod/${podName} rollout status: ${podStatus.phase}`);
    }
}
github microsoft / azure-pipelines-tasks / Tasks / UseDotNetV2 / Tests / versionInstallerTests.ts View on Github external
    error: function (errorMessage) { return tl.error(errorMessage); },
    getVariable: function (variableName) { return tl.getVariable(variableName); },
github alcideio / pipeline / azure-devops / tasks / advisor / utilities.ts View on Github external
export function assertFileExists(path: string) {
    if(!fs.existsSync(path)) {
        tl.error(tl.loc('FileNotFoundException', path));
        throw new Error(tl.loc('FileNotFoundException', path));
    }
}
github microsoft / azure-pipelines-tasks / Tasks / FtpUploadV2 / ftpuploadtask.ts View on Github external
if (!ftpOptions.serverEndpointUrl.hostname) {
        tl.setResult(tl.TaskResult.Failed, tl.loc("FTPNoHostSpecified"));
    }

    const files: string[] = findFiles(ftpOptions);
    const tracker = new ProgressTracker(ftpOptions, files.length);
    if (files.length === 0) {
        tl.warning(tl.loc("NoFilesFound"));
        return;
    }
   
    let ftpClient: ftp.Client;
    try {
        ftpClient = await getFtpClient(ftpOptions);
    } catch (err) {
        tl.error(err);
        tl.setResult(tl.TaskResult.Failed, tl.loc("UploadFailed"));

        return;
    }

    let sleep = (milliseconds: number) => {
        return new Promise(resolve => setTimeout(resolve, milliseconds));
    }

    let retryWithNewClient = async (task: () => {}, retry: number) => {
        let e = null;
        while (retry > 0) {
            try {
                await task();
                return;
            } catch (err) {
github lukka / CppBuildTasks / task-cmake / src / cmake-task.ts View on Github external
async function main(): Promise {
  try {
    tl.setResourcePath(path.join(__dirname, 'task.json'));
    let runner: cmakerunner.CMakeRunner = new cmakerunner.CMakeRunner();
    await runner.run();
    tl.setResult(tl.TaskResult.Succeeded, tl.loc('CMakeSuccess'));
    return;
  } catch (err) {
    tl.debug('Error: ' + err);
    tl.error(err);
    tl.setResult(tl.TaskResult.Failed, tl.loc('CMakeFailed', err));
    return;
  }
}
github lukka / CppBuildTasks / task-vcpkg / src / vcpkg-task.ts View on Github external
async function main(): Promise {
  try {
    tl.setResourcePath(path.join(__dirname, 'task.json'));
    let runner: vcpkgrunner.VcpkgRunner = new vcpkgrunner.VcpkgRunner();
    await runner.run();
    tl.setResult(tl.TaskResult.Succeeded, tl.loc('vcpkgSucceeded'));
    return 0;
  } catch (err) {
    tl.debug('Error: ' + err);
    tl.error(err);
    tl.setResult(tl.TaskResult.Failed, tl.loc('vcpkgFailed', err));
    return -1000;
  }
}
github microsoft / azure-pipelines-tasks / Tasks / Common / docker-common-v2 / containerconnection.ts View on Github external
private writeDockerConfigJson(dockerConfigContent: string, configurationFilePath?: string): void {
        if (!configurationFilePath){
            this.configurationDirPath  = this.getDockerConfigDirPath();
            process.env["DOCKER_CONFIG"] = this.configurationDirPath;
            configurationFilePath = path.join(this.configurationDirPath, "config.json");    
        }
    
        tl.debug(tl.loc('WritingDockerConfigToTempFile', configurationFilePath, dockerConfigContent));
        if(fileutils.writeFileSync(configurationFilePath, dockerConfigContent) == 0) {
            tl.error(tl.loc('NoDataWrittenOnFile', configurationFilePath));
            throw new Error(tl.loc('NoDataWrittenOnFile', configurationFilePath));
        }
    }
github alcideio / pipeline / azure-devops / tasks / advisor / clusterconnection.ts View on Github external
public setKubeConfigEnvVariable() {
        if (this.kubeconfigFile && fs.existsSync(this.kubeconfigFile)) {
            tl.setVariable("KUBECONFIG", this.kubeconfigFile);
        }
        else {
            tl.error(tl.loc('KubernetesServiceConnectionNotFound'));
            throw new Error(tl.loc('KubernetesServiceConnectionNotFound'));
        }
    }