Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var jarsigning = (fn: string) => {
// file must exist
tl.checkPath(fn, 'file to sign');
var jarsigner = tl.which("jarsigner", false);
if (!jarsigner) {
var java_home = tl.getVariable('JAVA_HOME');
if (!java_home) {
throw tl.loc('JavaHomeNotSet');
}
jarsigner = tl.resolve(java_home, 'bin', 'jarsigner');
}
var jarsignerRunner = tl.tool(jarsigner);
// Get keystore file path for signing
var keystoreFile = tl.getTaskVariable('KEYSTORE_FILE_PATH');
// Get keystore alias
var keystoreAlias = tl.getInput('keystoreAlias', true);
var keystorePass = tl.getInput('keystorePass', false);
var keyPass = tl.getInput('keyPass', false);
var jarsignerArguments = tl.getInput('jarsignerArguments', false);
jarsignerRunner.arg(['-keystore', keystoreFile]);
if (keystorePass) {
}
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);
}
private detectMachineOS(): string[] {
let osSuffix = [];
let scriptRunner: trm.ToolRunner;
try {
console.log(tl.loc("DetectingPlatform"));
if (tl.osType().match(/^Win/)) {
let escapedScript = path.join(this.getCurrentDir(), 'externals', 'get-os-platform.ps1').replace(/'/g, "''");
let command = `& '${escapedScript}'`
let powershellPath = tl.which('powershell', true);
scriptRunner = tl.tool(powershellPath)
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
.arg(command);
}
else {
let scriptPath = path.join(this.getCurrentDir(), 'externals', 'get-os-distro.sh');
this.setFileAttribute(scriptPath, "777");
scriptRunner = tl.tool(tl.which(scriptPath, true));
}
let result: trm.IExecSyncResult = scriptRunner.execSync();
if (result.code != 0) {
throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
}
private detectMachineOS(): string[] {
let osSuffix = [];
let scriptRunner: trm.ToolRunner;
try {
console.log(tl.loc("DetectingPlatform"));
if (tl.osType().match(/^Win/)) {
let escapedScript = path.join(this.getCurrentDir(), 'externals', 'get-os-platform.ps1').replace(/'/g, "''");
let command = `& '${escapedScript}'`
let powershellPath = tl.which('powershell', true);
scriptRunner = tl.tool(powershellPath)
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
.arg(command);
}
else {
let scriptPath = path.join(this.getCurrentDir(), 'externals', 'get-os-distro.sh');
this.setFileAttribute(scriptPath, "777");
scriptRunner = tl.tool(tl.which(scriptPath, true));
}
let result: trm.IExecSyncResult = scriptRunner.execSync();
if (result.code != 0) {
throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
}
public describe(resourceType: string, resourceName: string, silent?: boolean): IExecSyncResult {
const command = tl.tool(this.kubectlPath);
command.arg('describe');
command.arg([resourceType, resourceName]);
return this.execute(command, silent);
}
public annotate(resourceType: string, resourceName: string, annotations: string[], overwrite?: boolean): IExecSyncResult {
const command = tl.tool(this.kubectlPath);
command.arg('annotate');
command.arg([resourceType, resourceName]);
command.arg(annotations);
if (!!overwrite) { command.arg(`--overwrite`); }
return this.execute(command);
}
public scale(resourceType: string, resourceName: string, replicas: any) {
const command = tl.tool(this.kubectlPath);
command.arg('scale');
command.arg(resourceType + '/' + resourceName);
command.arg(`--replicas=${replicas}`);
return this.execute(command);
}
private async translateWindowsPath(windowsPath: string): Promise {
const pwd = tool(which('bash', true))
.arg('--noprofile')
.arg('--norc')
.arg('-c')
.arg('pwd')
const options = {
cwd: windowsPath,
errStream: process.stdout,
outStream: process.stdout,
failOnStdErr: true,
ignoreReturnCode: false
}
let unixPath = ''
pwd.on('stdout', (c: string | symbol) => (unixPath += c.toString()))
await pwd.exec((options as unknown) as IExecOptions)
unixPath = unixPath.trim()
public getDeleteSecretCommand(secretName: string, namespace: string): tr.ToolRunner {
const command = tl.tool(this.kubectlPath);
command.arg(['delete', 'secret', secretName]);
if (namespace) {
command.arg(['--namespace', namespace]);
}
return command;
}
}
public getAllPods(): IExecSyncResult {
const command = tl.tool(this.kubectlPath);
command.arg('get');
command.arg('pods');
command.arg(['-o', 'json']);
return this.execute(command, true);
}