How to use the azure-pipelines-task-lib/task.warning 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 / ContainerBuildV0 / src / dockerpush.ts View on Github external
export async function run(connection: ContainerConnection) {

    // get tags input
    let tags = tl.getDelimitedInput("tags", "\n");

    // get repository input
    let repositoryName = tl.getInput("repository");
    if (!repositoryName) {
        tl.warning("No repository is specified. Nothing will be pushed.");
    }

    let imageNames: string[] = [];
    // if container registry is provided, use that
    // else, use the currently logged in registries
    if (tl.getInput("dockerRegistryServiceConnection")) {
        let imageName = connection.getQualifiedImageName(repositoryName, true);
        if (imageName) {
            imageNames.push(imageName);
        }
    }
    else {
        imageNames = connection.getQualifiedImageNamesFromConfig(repositoryName, true);
    }

    await pushMultipleImages(connection, imageNames, tags, "");
github aws / aws-vsts-tools / Tasks / CloudFormationCreateOrUpdateStack / TaskOperations.ts View on Github external
const knownNoOpErrorMessages = [
            /^No updates are to be performed./,
            /^The submitted information didn't contain changes./
        ]

        try {
            if (errCodeOrStatus.search(/ValidationError/) !== -1 || errCodeOrStatus.search(/FAILED/) !== -1) {
                knownNoOpErrorMessages.forEach(element => {
                    if (errMessage.search(element) !== -1) {
                        noWorkToDo = true
                    }
                })
            }
            if (noWorkToDo) {
                if (this.taskParameters.warnWhenNoWorkNeeded) {
                    tl.warning(tl.loc('NoWorkToDo'))
                }

                return true
            }
            // tslint:disable-next-line:no-empty
        } catch (err) {}

        return false
    }
github microsoft / azure-pipelines-tasks / Tasks / KubernetesManifestV0 / src / utils / DeploymentHelper.ts View on Github external
kubectl.getResource(constants.DiscoveryAndLoadBalancerResource.ingress, ingressResource.name);
    });

    // annotate resources
    const allPods = JSON.parse((kubectl.getAllPods()).stdout);
    annotateResources(deployedManifestFiles, kubectl, resourceTypes, allPods);

    // Capture and push deployment metadata only if the variable 'PUBLISH_PIPELINE_METADATA' is set to true,
    // and deployment strategy is not specified (because for Canary/SMI we do not replace actual deployment objects)
    if (publishPipelineMetadata && publishPipelineMetadata.toLowerCase() == "true" && !isCanaryDeploymentStrategy(deploymentStrategy)) {
        try {
            const clusterInfo = kubectl.getClusterInfo().stdout;
            captureAndPushDeploymentMetadata(inputManifestFiles, allPods, deploymentStrategy, clusterInfo, manifestFilePaths);
        }
        catch (e) {
            tl.warning("Capturing deployment metadata failed with error: " + e);
        }
    }
}
github microsoft / azure-pipelines-tasks / Tasks / VsTestPlatformToolInstallerV1 / nugetdownloadhelper.ts View on Github external
private async acquireAndCacheVsTestPlatformNuget(packageSource: string, testPlatformVersion: string, nugetConfigFilePath: string): Promise {
        testPlatformVersion = toolLib.cleanVersion(testPlatformVersion);
        const nugetTool = tl.tool(path.join(__dirname, 'nuget.exe'));
        let downloadPath = helpers.getTempFolder();

        // Ensure Agent.TempDirectory is set
        if (!downloadPath) {
            throw new Error(tl.loc('ExpectedTempToBeSet'));
        }

        // Call out a warning if the agent work folder path is longer than 50 characters as anything longer may cause the download to fail
        // Note: This upper limit was calculated for a particular test platform package version and is subject to change
        if (tl.getVariable(constants.agentWorkFolder) && tl.getVariable(constants.agentWorkFolder).length > 50) {
            ci.addToConsolidatedCi('agentWorkDirectoryPathTooLong', 'true');
            tl.warning(tl.loc('AgentWorkDirectoryPathTooLong'));
        }

        // Use as short a path as possible due to nested folders in the package that may potentially exceed the 255 char windows path limit
        downloadPath = path.join(downloadPath, constants.toolFolderName);
        nugetTool.arg(constants.install).arg(constants.packageId).arg(constants.version).arg(testPlatformVersion).arg(constants.source)
            .arg(packageSource).arg(constants.outputDirectory).arg(downloadPath).arg(constants.noCache).arg(constants.directDownload)
            .argIf(nugetConfigFilePath, constants.configFile).argIf(nugetConfigFilePath, nugetConfigFilePath).arg(constants.noninteractive);

        tl.debug(`Downloading Test Platform version ${testPlatformVersion} from ${packageSource} to ${downloadPath}.`);
        startTime = perf();
        const resultCode = await nugetTool.exec();
        ci.addToConsolidatedCi('downloadTime', perf() - startTime);

        tl.debug(`Nuget.exe returned with result code ${resultCode}`);

        if (resultCode !== 0) {
github microsoft / azure-pipelines-tasks / Tasks / Common / kubernetes-common-v2 / kubernetesmanifestutility.ts View on Github external
podStatus = getPodStatus(kubectl, podName);
        if (podStatus.phase && podStatus.phase !== 'Pending' && podStatus.phase !== 'Unknown') {
            break;
        }
    }
    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 / Common / kubernetes-common-v2 / kubernetesmanifestutility.ts View on Github external
function isPodReady(podStatus: any): boolean {
    let allContainersAreReady = true;
    podStatus.containerStatuses.forEach(container => {
        if (container.ready === false) {
            console.log(`'${container.name}' status: ${JSON.stringify(container.state)}`);
            allContainersAreReady = false;
        }
    });
    if (!allContainersAreReady) {
        tl.warning(tl.loc('AllContainersNotInReadyState'));
    }
    return allContainersAreReady;
}
github microsoft / azure-pipelines-tasks / Tasks / KubernetesManifestV0 / src / utils / DeploymentHelper.ts View on Github external
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 / Common / kubernetes-common-v2 / utility.ts View on Github external
export function checkForErrors(execResults: IExecSyncResult[], warnIfError?: boolean) {
    if (execResults.length !== 0) {
        let stderr = '';
        execResults.forEach(result => {
            if (result.stderr) {
                if (result.code !== 0) {
                    stderr += result.stderr + '\n';
                } else {
                    tl.warning(result.stderr);
                }
            }
        });
        if (stderr.length > 0) {
            if (!!warnIfError) {
                tl.warning(stderr.trim());
            } else {
                throw new Error(stderr.trim());
            }
        }
    }
}
github microsoft / azure-pipelines-tasks / Tasks / DockerV2 / dockerbuildandpush.ts View on Github external
export function run(connection: ContainerConnection, outputUpdate: (data: string) => any): any {
    let args = tl.getInput("arguments");
    if (args) {
        tl.warning(tl.loc('IgnoringArgumentsInput'));
    }

    let dockerbuild = require("./dockerbuild");
    let dockerpush = require("./dockerpush");

    let outputPaths = "";
    let promise = dockerbuild.run(connection, (outputPath) => outputPaths += outputPath, true).then(() => {
        return dockerpush.run(connection, (outputPath) => outputPaths += ("\n" + outputPath), true).then(() => {
            outputUpdate(outputPaths);
        });
    })
    
    return promise;
}