Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function run() {
let registryAuthenticationToken: RegistryCredential = getRegistryAuthenticationToken();
let bypassModules = tl.getInput('bypassModules');
if (bypassModules == null) bypassModules = "";
tl.debug(`Bypass Modules are: ${bypassModules}`);
let templateFilePath: string = tl.getPathInput("templateFilePath", true);
tl.debug(`The template file path is ${templateFilePath}`);
if (!fs.existsSync(templateFilePath)) {
throw Error(tl.loc('TemplateFileInvalid', templateFilePath));
}
util.setTaskRootPath(path.dirname(templateFilePath));
util.setupIotedgedev();
/*
* iotedgedev will use registry server url to match which credential to use in push process
* For example, a normal docker hub credential should have server: https://index.docker.io/v1/ I would like to push to michaeljqzq/repo:0.0.1
* But if I set CONTAINER_REGISTRY_SERVER=https://index.docker.io/v1/ in environment variable, it won't work.
* iotedgedev won't load this credential
* instead, the CONTAINER_REGISTRY_SERVER should be set to michaeljqzq
* However, "michaeljqzq" is not in the scope of a credential.
* So here is a work around to login in advanced call to `iotedgedev push` and then logout after everything done.
let nuGetAdditionalArgs = tl.getInput("nuGetAdditionalArgs");
let verbosity = tl.getInput("verbosity");
let nuGetFeedType = tl.getInput("nuGetFeedType") || "external";
// make sure the feed type is an expected one
let normalizedNuGetFeedType
= ["internal", "external"].find(x => nuGetFeedType.toUpperCase() === x.toUpperCase());
if (!normalizedNuGetFeedType) {
throw new Error(tl.loc("UnknownFeedType", nuGetFeedType));
}
nuGetFeedType = normalizedNuGetFeedType;
// due to a bug where we accidentally allowed nuGetPath to be surrounded by quotes before,
// locateNuGetExe() will strip them and check for existence there.
let nuGetPath = tl.getPathInput("nuGetPath", false, false);
let nugetUxOption = tl.getInput("nuGetversion");
let userNuGetProvided = false;
if (nuGetPath !== null && tl.filePathSupplied("nuGetPath")) {
nuGetPath = nutil.stripLeadingAndTrailingQuotes(nuGetPath);
userNuGetProvided = true;
if (nugetUxOption !== "custom")
{
// For back compat, if a path has already been specified then use it.
// However, warn the user in the build of this behavior.
tl.warning(tl.loc("Warning_ConflictingNuGetPreference"));
}
}
else {
if (nugetUxOption === "custom")
{
throw new Error(tl.loc("NoNuGetSpecified"))
filesList.forEach(solutionFile => {
let solutionPath;
if (!fs.lstatSync(solutionFile).isDirectory()) {
solutionPath = path.dirname(solutionFile);
} else {
solutionPath = solutionFile;
}
let targetResolveRepo = tl.getInput("targetResolveRepo");
let nugetArguments = addNugetArgsToCommands();
nugetCommandCli = utils.cliJoin(cliPath, cliNuGetCommand, nugetCommand, targetResolveRepo, "--solution-root=" + utils.quote(solutionPath), "--nuget-args=" + utils.quote(nugetArguments));
runNuGet(nugetCommandCli, cliPath, buildDir);
});
} else {
// Perform push command.
let targetDeployRepo = tl.getInput("targetDeployRepo");
let pathToNupkg = utils.fixWindowsPaths(tl.getPathInput("pathToNupkg", true, false));
nugetCommandCli = utils.cliJoin(cliPath, cliUploadCommand, pathToNupkg, targetDeployRepo);
runNuGet(nugetCommandCli, cliPath, buildDir);
}
}
import * as npmutil from "./packaging/npm/npmutil";
import * as util from "./packaging/util";
import { INpmRegistry, NpmRegistry } from "./packaging/npm/npmregistry";
import {
PackagingLocation,
getPackagingUris,
ProtocolType
} from "./packaging/locationUtilities";
import { RegistryLocation } from "./constants";
tl.setResourcePath(path.join(__dirname, "task.json"));
let yarnPath = tl.which("yarn");
let args = tl.getInput("arguments");
let projectPath = tl.getPathInput("projectDirectory") || process.cwd();
let customRegistry = tl.getInput("customRegistry");
function projectNpmrc(): string {
return path.join(projectPath, ".npmrc");
}
function saveProjectNpmrc(overrideProjectNpmrc: boolean): void {
if (overrideProjectNpmrc) {
tl.debug("OverridingProjectNpmrc: " + projectNpmrc());
util.saveFile(projectNpmrc());
tl.rmRF(projectNpmrc());
}
}
async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
tl.debug('Prepare task inputs.');
const authType: string = tl.getInput('authType', true);
let key: googleutil.ClientKey = {};
if (authType === 'JsonFile') {
const serviceAccountKeyFile: string = tl.getPathInput('serviceAccountKey', true, true);
const stats: tl.FsStats = tl.stats(serviceAccountKeyFile);
if (stats && stats.isFile()) {
key = require(serviceAccountKeyFile);
} else {
tl.debug(`The service account file path ${serviceAccountKeyFile} points to a directory.`);
throw new Error(tl.loc('InvalidAuthFile', serviceAccountKeyFile));
}
} else if (authType === 'ServiceEndpoint') {
let serviceEndpoint: tl.EndpointAuthorization = tl.getEndpointAuthorization(tl.getInput('serviceEndpoint', true), false);
key.client_email = serviceEndpoint.parameters['username'];
key.private_key = serviceEndpoint.parameters['password'].replace(/\\n/g, '\n');
}
const packageName: string = tl.getInput('applicationId', true);
tl.debug(`Application identifier: ${packageName}`);
scriptType: getInputRequired('scriptType'),
filePath: '',
inlineScript: '',
disableAutoCwd: getBoolInput('disableAutoCwd', false),
workingDirectory: '',
failOnStandardError: getBoolInput('failOnStandardError', false)
}
if (parameters.scriptType === fileScriptType) {
parameters.filePath = getPathInput('filePath', true, true)
} else {
parameters.inlineScript = getInputRequired('inlineScript')
}
if (parameters.disableAutoCwd) {
parameters.workingDirectory = getPathInput('workingDirectory', true, false)
}
return parameters
}
import * as tl from "azure-pipelines-task-lib/task";
import patchProcess = require("./common/patchProcess");
import yamlPatcher = require("./yamlPatcher");
import { Operation } from "fast-json-patch";
var targetPath = tl.getPathInput("YamlWorkingDir");
var patchContent = tl.getInput("YamlPatchContent");
var patterns: any = tl.getInput("YamlTargetFilters");
var outputPatchedFile = tl.getBoolInput("OutputPatchFile");
var failIfNoPatchApplied = tl.getBoolInput("FailIfNoPatchApplied");
var treatErrors = tl.getInput("TreatErrors");
var syntax = tl.getInput("SyntaxType");
try {
var patches: Operation[] =
syntax == "slick"
? patchProcess.expandVariablesAndParseSlickPatch(patchContent)
: patchProcess.expandVariablesAndParseJson(patchContent);
patchProcess.apply(
new yamlPatcher.YamlPatcher(patches),
tracingConfig: getInputOrEmpty('tracingConfig'),
outputVariable: getInputOrEmpty('outputVariable')
}
if (parameters.deploymentMode === deployCodeAndConfig) {
parameters.functionHandler = getInputRequired('functionHandler')
parameters.runtime = getInputRequired('runtime')
parameters.roleARN = getInputRequired('roleARN')
} else {
parameters.functionHandler = getInputOrEmpty('functionHandler')
parameters.runtime = getInputOrEmpty('runtime')
parameters.roleARN = getInputOrEmpty('roleARN')
}
if (parameters.codeLocation === updateFromLocalFile) {
parameters.localZipFile = tl.getPathInput('localZipFile', true, true)
} else {
parameters.s3Bucket = getInputRequired('s3Bucket')
parameters.s3ObjectKey = getInputRequired('s3ObjectKey')
parameters.s3ObjectVersion = tl.getInput('s3ObjectVersion', false)
}
const memorySizeTmp = tl.getInput('memorySize', false)
if (memorySizeTmp) {
const parsedInt = parseInt(memorySizeTmp, 10)
if (!isNaN(parsedInt)) {
parameters.memorySize = parsedInt
}
}
const timeoutTmp = tl.getInput('timeout', false)
if (timeoutTmp) {
export function getBuildContext(dockerFile: string): string {
let buildContext = tl.getPathInput("buildContext");
if (useDefaultBuildContext(buildContext)) {
buildContext = path.dirname(dockerFile);
}
return buildContext;
}