How to use the azure-pipelines-task-lib/task.loc 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 / versioninstaller.ts View on Github external
directoriesTobeCopied.forEach((directoryPath) => {
                tl.cp(directoryPath, this.installationPath, "-rf", false);
            });

            // Copy files
            try {
                if (this.packageType == utils.Constants.sdk && this.isLatestInstalledVersion(version)) {
                    tl.debug(tl.loc("CopyingFilesIntoPath", this.installationPath));
                    var filesToBeCopied = allRootLevelEnteriesInDir.filter(path => !fs.lstatSync(path).isDirectory());
                    filesToBeCopied.forEach((filePath) => {
                        tl.cp(filePath, this.installationPath, "-f", false);
                    });
                }
            }
            catch (ex) {
                tl.warning(tl.loc("FailedToCopyTopLevelFiles", this.installationPath, ex));
            }

            // Cache tool
            this.createInstallationCompleteFile(versionInfo);

            console.log(tl.loc("SuccessfullyInstalled", this.packageType, version));
        }
        catch (ex) {
            throw tl.loc("FailedWhileInstallingVersionAtPath", version, this.installationPath, ex);
        }
    }
github microsoft / azure-pipelines-tasks / Tasks / AndroidSigningV2 / androidsigning.ts View on Github external
var android_home = tl.getVariable('ANDROID_HOME');
        if (!android_home) {
            throw tl.loc('AndroidHomeNotSet');
        }

        var zipalignToolsList = tl.findMatch(tl.resolve(android_home, 'build-tools'), "zipalign*", null, { matchBase: true });

        if (!zipalignToolsList || zipalignToolsList.length === 0) {
            throw tl.loc('CouldNotFindZipalignInAndroidHome', android_home);
        }

        zipaligner = zipalignToolsList[0];
    }

    if (!zipaligner) {
        throw tl.loc('CouldNotFindZipalign');
    }

    var zipalignRunner = tl.tool(zipaligner);

    // alignment must be 4 or play store will reject, hard code this to avoid user errors
    zipalignRunner.arg(["-v", "4"]);

    var unalignedFn = fn + ".unaligned";
    var success = tl.mv(fn, unalignedFn, '-f', false);

    zipalignRunner.arg([unalignedFn, fn]);
    return zipalignRunner.exec(null);
}
github microsoft / azure-pipelines-tasks / Tasks / DotNetCoreInstallerV1 / versioninstaller.ts View on Github external
}
        }) < 0;

        var filePaths: string[] = allEnteries.filter(element => !fs.lstatSync(element).isDirectory());
        isLatest = isLatest && filePaths.findIndex(filePath => {
            try {
                var versionCompleteFileName = this.getVersionCompleteFileName(path.basename(filePath));
                tl.debug(tl.loc("ComparingInstalledFileVersions", version, versionCompleteFileName));
                return utils.versionCompareFunction(versionCompleteFileName, version) > 0
            }
            catch (ex) {
                // no op, file name might not be in version format
            }
        }) < 0;

        isLatest ? tl.debug(tl.loc("VersionIsLocalLatest", version, this.installationPath)) : tl.debug(tl.loc("VersionIsNotLocalLatest", version, this.installationPath));
        return isLatest;
    }
github microsoft / azure-pipelines-tasks / Tasks / DotNetCoreInstallerV1 / versionfetcher.ts View on Github external
let index;
            if ((index = output.indexOf("Primary:")) >= 0) {
                let primary = output.substr(index + "Primary:".length).split(os.EOL)[0];
                osSuffix.push(primary);
                console.log(tl.loc("PrimaryPlatform", primary));
            }

            if ((index = output.indexOf("Legacy:")) >= 0) {
                let legacy = output.substr(index + "Legacy:".length).split(os.EOL)[0];
                osSuffix.push(legacy);
                console.log(tl.loc("LegacyPlatform", legacy));
            }

            if (osSuffix.length == 0) {
                throw tl.loc("CouldNotDetectPlatform");
            }
        }
        catch (ex) {
            throw tl.loc("FailedInDetectingMachineArch", JSON.stringify(ex));
        }

        return osSuffix;
    }
github microsoft / azure-pipelines-tasks / Tasks / UseDotNetV2 / 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 aws / aws-vsts-tools / Tasks / CloudFormationExecuteChangeSet / TaskOperations.ts View on Github external
console.log(tl.loc('SettingOutputVariable', this.taskParameters.outputVariable))
                tl.setVariable(this.taskParameters.outputVariable, stackId)
            }

            if (this.taskParameters.captureStackOutputs !== ignoreStackOutputs) {
                await captureStackOutputs(
                    this.cloudFormationClient,
                    this.taskParameters.stackName,
                    this.taskParameters.captureStackOutputs === stackOutputsAsJson,
                    this.taskParameters.captureAsSecuredVars
                )
            }

            console.log(tl.loc('TaskCompleted', this.taskParameters.changeSetName))
        } catch (err) {
            console.error(tl.loc('ExecuteChangeSetFailed', (err as Error).message), err)
            throw err
        }
    }
github aws / aws-vsts-tools / Tasks / BeanstalkDeployApplication / TaskParameters.ts View on Github external
const parameters: TaskParameters = {
        awsConnectionParameters: buildConnectionParameters(),
        applicationName: getInputRequired('applicationName'),
        environmentName: getInputRequired('environmentName'),
        applicationType: getInputRequired('applicationType'),
        versionLabel: '',
        webDeploymentArchive: '',
        dotnetPublishPath: '',
        deploymentBundleBucket: '',
        deploymentBundleKey: '',
        description: getInputOrEmpty('description'),
        outputVariable: getInputOrEmpty('outputVariable'),
        eventPollingDelay: defaultEventPollingDelaySeconds
    }

    console.log(tl.loc('DisplayApplicationType', parameters.applicationType))

    switch (parameters.applicationType) {
        case applicationTypeAspNet:
            parameters.webDeploymentArchive = tl.getPathInput('webDeploymentArchive', true)
            break

        case applicationTypeAspNetCoreForWindows:
            parameters.dotnetPublishPath = tl.getPathInput('dotnetPublishPath', true)
            break

        case applicationTypeS3Archive:
            parameters.deploymentBundleBucket = getInputRequired('deploymentBundleBucket')
            parameters.deploymentBundleKey = getInputRequired('deploymentBundleKey')
            break

        default:
github microsoft / azure-pipelines-tasks / Tasks / DownloadPackageV0 / download.ts View on Github external
function getAuthToken() {
	var auth = tl.getEndpointAuthorization('SYSTEMVSSCONNECTION', false);
	if (auth.scheme.toLowerCase() === 'oauth') {
		return auth.parameters['AccessToken'];
	}
	else {
		throw new Error(tl.loc("CredentialsNotFound"))
	}
}
github microsoft / azure-pipelines-tasks / Tasks / NuGetPublisherV0 / nugetpublisher.ts View on Github external
await publishPackageAsync(packageFile, publishOptions);
            }
        } finally {
            credCleanup();
        }

        tl.setResult(tl.TaskResult.Succeeded, tl.loc("PackagesPublishedSuccessfully"));

    } catch (err) {
        tl.error(err);

        if (buildIdentityDisplayName || buildIdentityAccount) {
            tl.warning(tl.loc("BuildIdentityPermissionsHint", buildIdentityDisplayName, buildIdentityAccount));
        }

        tl.setResult(tl.TaskResult.Failed, tl.loc("PackagesFailedToPublish"));
    }
}
github microsoft / azure-pipelines-tasks / Tasks / KubernetesManifestV0 / src / utils / KubernetesObjectUtility.ts View on Github external
export function isDeploymentEntity(kind: string): boolean {
    if (!kind) {
        throw (tl.loc('ResourceKindNotDefined'));
    }

    return deploymentTypes.some((type: string) => {
        return isEqual(type, kind, StringComparer.OrdinalIgnoreCase);
    });
}