function updateGlobalParams(paramName, value) { tl.debug("Updating Global Parameters"); tl.debug("SETTING " + paramName + " TO " + JSON.stringify(value)); globalParams.params[paramName] = value; google.options(globalParams); tl.debug("Global Params set to " + JSON.stringify(globalParams)); }
fs.readFile(file, 'utf8', function (err, data) { if (err) { tl.error("Could not read file " + filePath + ". Error is " + err.message); tl.exit(1); } var reg = new RegExp(tokenRegex, "g"); console.info("Starting regex replacement in " + file); // loop through each match var match; while ((match = reg.exec(data)) !== null) { // find the variable value in the environment var varName = match[1]; var varValue = tl.getVariable(varName); if (varValue === null) { tl.warning("... token " + varName + " does not have an environment value"); } else { data = data.replace(match[0], varValue); tl.debug("... replaced token " + varName); } } console.info("Writing new values to file"); fs.writeFileSync(file, data); tl.debug("Leaving Replace Tokens step"); });
/** * Gets information for the specified app and track * Assumes authorized * @param {string} packageName - unique android package name (com.android.etc) * @param {string} track - one of the values {"alpha", "beta", "production", "rollout"} * @returns {Promise} track - A promise that will return result from updating a track * { track: string, versionCodes: [integer], userFraction: double } */ function getTrack(packageName, track) { tl.debug("Getting Track information"); var requestParameters = { packageName: packageName, track: track }; tl.debug("Additional Parameters: " + JSON.stringify(requestParameters)); return edits.tracks.getAsync(requestParameters); }
/** * Uses the provided JWT client to request a new edit from the Play store and attach the edit id to all requests made this session * Assumes authorized * @param {string} packageName - unique android package name (com.android.etc) * @return {Promise} edit - A promise that will return result from inserting a new edit * { id: string, expiryTimeSeconds: string } */ function getNewEdit(packageName) { tl.debug("Creating a new edit"); var requestParameters = { packageName: packageName }; tl.debug("Additional Parameters: " + JSON.stringify(requestParameters)); return edits.insertAsync(requestParameters).then(function (res) { updateGlobalParams("editId", res[0].id); return res; }); }
/** * Update a given release track with the given information * Assumes authorized * @param {string} packageName - unique android package name (com.android.etc) * @param {string} track - one of the values {"alpha", "beta", "production", "rollout"} * @param {integer or [integers]} versionCode - version code returned from an apk call. will take either a number or a [number] * @param {double} userFraction - for rollout, fraction of users to get update * @returns {Promise} track - A promise that will return result from updating a track * { track: string, versionCodes: [integer], userFraction: double } */ function updateTrack(packageName, track, versionCode, userFraction) { tl.debug("Updating track"); var requestParameters = { packageName: packageName, track: track, resource: { track: track, versionCodes: (typeof versionCode === "number" ? [versionCode] : versionCode) } }; if (track == "rollout") { requestParameters.resource.userFraction = userFraction; } tl.debug("Additional Parameters: " + JSON.stringify(requestParameters)); return edits.tracks.updateAsync(requestParameters); }
function packageNativeLibraries(nativeLibraryPath) { var packageName = path.basename(nativeLibraryPath) + ".zip" var packagePath = path.join(path.dirname(nativeLibraryPath), packageName); tl.debug("Creating a native library file: " + packagePath); // TODO: Add support for wildcard paths var zip = new Zip(); zip.file(path.basename(nativeLibraryPath), fs.readFileSync(nativeLibraryPath)); var data = zip.generate({ base64: false, compression: "DEFLATE" }); fs.writeFileSync(packagePath, data, "binary"); return packagePath; }
function publishTestResults(publishJUnitResults, testResultsFiles) { if(publishJUnitResults == 'true') { //check for pattern in testResultsFiles if(testResultsFiles.indexOf('*') >= 0 || testResultsFiles.indexOf('?') >= 0) { tl.debug('Pattern found in testResultsFiles parameter'); var buildFolder = tl.getVariable('agent.buildDirectory'); var allFiles = tl.find(buildFolder); var matchingTestResultsFiles = tl.match(allFiles, testResultsFiles, { matchBase: true }); } else { tl.debug('No pattern found in testResultsFiles parameter'); var matchingTestResultsFiles = [testResultsFiles]; } if(!matchingTestResultsFiles) { tl.warning('No test result files matching ' + testResultsFiles + ' were found, so publishing JUnit test results is being skipped.'); return 0; } var tp = new tl.TestPublisher("JUnit"); tp.publish(matchingTestResultsFiles, false, "", ""); } }
function packageSymbols(symbolsPath) { var packageName = path.basename(symbolsPath) + ".zip" var packagePath = path.join(symbolsPath, "..", packageName); tl.debug("Creating a symbols package file: " + packagePath); var zip = new Zip(); var filePaths = getAllFiles(symbolsPath, /*recursive=*/ true); for (var i = 0; i < filePaths.length; i++) { var filePath = filePaths[i]; var relativePath = path.relative(symbolsPath, filePath); zip.file(relativePath, fs.readFileSync(filePath)); } var data = zip.generate({ base64: false, compression: 'DEFLATE' }); fs.writeFileSync(packagePath, data, 'binary'); return packagePath; }
var onFailedExecution = function (err) { // Error executing tl.debug('ToolRunner execution failure: ' + err); tl.exit(1); }
// update JAVA_HOME if user selected specific JDK version var jdkVersion = tl.getInput('jdkVersion'); var jdkArchitecture = tl.getInput('jdkArchitecture'); if(jdkVersion != 'default') { // jdkVersion should be in the form of 1.7, 1.8, or 1.10 // jdkArchitecture is either x64 or x86 // envName for version 1.7 and x64 would be "JAVA_HOME_7_X64" var envName = "JAVA_HOME_" + jdkVersion.slice(2) + "_" + jdkArchitecture.toUpperCase(); var specifiedJavaHome = tl.getVariable(envName); if (!specifiedJavaHome) { tl.error('Failed to find specified JDK version. Please make sure environment varialbe ' + envName + ' exists and is set to a valid JDK.'); tl.exit(1); } tl.debug('Set JAVA_HOME to ' + specifiedJavaHome); process.env['JAVA_HOME'] = specifiedJavaHome; } var publishJUnitResults = tl.getInput('publishJUnitResults'); var testResultsFiles = tl.getInput('testResultsFiles', true); function publishTestResults(publishJUnitResults, testResultsFiles) { if(publishJUnitResults == 'true') { //check for pattern in testResultsFiles if(testResultsFiles.indexOf('*') >= 0 || testResultsFiles.indexOf('?') >= 0) { tl.debug('Pattern found in testResultsFiles parameter'); var buildFolder = tl.getVariable('agent.buildDirectory'); var allFiles = tl.find(buildFolder); var matchingTestResultsFiles = tl.match(allFiles, testResultsFiles, { matchBase: true }); }
.fail(function(err) { publishTestResults(publishJUnitResults, testResultsFiles); console.error(err.message); tl.debug('taskRunner fail'); tl.exit(1); })
binaryPath = checkAndFixFilePath(binaryPath, "symbolsPath"); symbolsPath = checkAndFixFilePath(symbolsPath, "symbolsPath"); nativeLibraryPath = checkAndFixFilePath(nativeLibraryPath, "nativeLibraryPath"); notesPath = checkAndFixFilePath(notesPath, "notesPath"); if (symbolsPath && fs.lstatSync(symbolsPath).isDirectory()) { symbolsPath = packageSymbols(symbolsPath); } // Native libraries must always be zipped, and therefore // we simply check for the presence of a path before zipping if (nativeLibraryPath) { nativeLibraryPath = packageNativeLibraries(nativeLibraryPath); } tl.debug("binaryPath: " + binaryPath || ""); tl.debug("symbolsPath: " + symbolsPath || ""); tl.debug("notesPath: " + notesPath || ""); var formData = { ipa: fs.createReadStream(binaryPath), dsym: symbolsPath ? fs.createReadStream(symbolsPath) : null, notes: notesPath ? fs.readFileSync(notesPath) : notes, lib: nativeLibraryPath ? fs.createReadStream(nativeLibraryPath) : null, notes_type: "1", // Markdown mandatory: mandatory ? "1" : "0", notify: notify ? "1" :"0", tags: tags, teams: teams, users: users, status: publish ? "2" : "1",
var tl = require('vso-task-lib'); var testRunner = tl.getInput('testRunner', true); var testResultsFiles = tl.getInput('testResultsFiles', true); var mergeResults = tl.getInput('mergeTestResults'); var platform = tl.getInput('platform'); var config = tl.getInput('configuration'); tl.debug('testRunner: ' + testRunner); tl.debug('testResultsFiles: ' + testResultsFiles); tl.debug('mergeResults: ' + mergeResults); tl.debug('platform: ' + platform); tl.debug('config: ' + config); //check for pattern in testResultsFiles if(testResultsFiles.indexOf('*') >= 0 || testResultsFiles.indexOf('?') >= 0) { tl.debug('Pattern found in testResultsFiles parameter'); var buildFolder = tl.getVariable('agent.buildDirectory'); var allFiles = tl.find(buildFolder); var matchingTestResultsFiles = tl.match(allFiles, testResultsFiles, { matchBase: true }); } else { tl.debug('No pattern found in testResultsFiles parameter'); var matchingTestResultsFiles = [testResultsFiles]; } if(!matchingTestResultsFiles) { tl.warning('No test result files matching ' + testResultsFiles + ' were found.'); tl.exit(0); }
antv.arg('-version'); var antb = new tl.ToolRunner(anttool); antb.arg('-buildfile'); antb.arg(tl.getPathInput('antBuildFile', true, true)); // options and targets are optional antb.arg(tl.getDelimitedInput('options', ' ', false)); antb.arg(tl.getDelimitedInput('targets', ' ', false)); // update JAVA_HOME if user selected specific JDK version or set path manually var javaHomeSelection = tl.getInput('javaHomeSelection', true); var specifiedJavaHome = null; if (javaHomeSelection == 'JDKVersion') { tl.debug('Using JDK version to find and set JAVA_HOME'); var jdkVersion = tl.getInput('jdkVersion'); var jdkArchitecture = tl.getInput('jdkArchitecture'); if(jdkVersion != 'default') { // jdkVersion should be in the form of 1.7, 1.8, or 1.10 // jdkArchitecture is either x64 or x86 // envName for version 1.7 and x64 would be "JAVA_HOME_7_X64" var envName = "JAVA_HOME_" + jdkVersion.slice(2) + "_" + jdkArchitecture.toUpperCase(); specifiedJavaHome = tl.getVariable(envName); if (!specifiedJavaHome) { tl.error('Failed to find specified JDK version. Please make sure environment variable ' + envName + ' exists and is set to the location of a corresponding JDK.'); tl.exit(1); } } }
.fail(function(err) { tl.debug('taskRunner fail'); tl.exit(1); })
.fail(function(err) { publishTestResults(publishJUnitResults, testResultsFiles); tl.debug('taskRunner fail'); tl.exit(1); })
var fs = require('fs'); var path = require('path'); var tl = require('vso-task-lib'); // Get configuration var configuration = tl.getInput('configuration', true); tl.debug('Configuration: ' + configuration); // Get and check path to solution file (.sln) var solutionPath = tl.getPathInput('solution', true, true); tl.debug('Solution path: ' + solutionPath); // Get whether to build for the iOS Simulator var buildForSimulator = tl.getInput('forSimulator', false); var device = (buildForSimulator == 'true') ? 'iPhoneSimulator' : 'iPhone'; tl.debug('Build for iOS Simulator: ' + buildForSimulator); tl.debug('Device: ' + device); // Get path to mdtool var mdtoolPath = tl.getInput('mdtoolLocation', false); if (!mdtoolPath) { // When no override location is provided, use the standard mdtool installation path mdtoolPath = '/Applications/Xamarin Studio.app/Contents/MacOS/mdtool'; } tl.debug('mdtool path: ' + mdtoolPath); // Check path to mdtool if (!fs.existsSync(mdtoolPath)) { tl.error('The path to mdtool does not exist: ' + mdtoolPath); tl.exit(1); }
var cwd = tl.getPathInput('cwd', false); var script = tl.getInput('script', false); var failOnStdErr = tl.getInput('failOnStandardError') == 'true'; var scriptPath = tl.getPathInput('scriptPath', false); var type = tl.getInput('type'); if(!type){ // nothing to do tl.warning("type is not mentioned") }else if(type == 'InlineScript'){ if (cwd == null || cwd == "") { cwd = "/tmp"; } tl.debug('using cwd: ' + cwd); tl.cd(cwd); scriptPath = cwd + "/user_script.sh"; fs.writeFileSync(scriptPath,script,'utf8'); bash.arg(scriptPath); bash.exec({ failOnStdErr: failOnStdErr}) .then(function(code) { // TODO: switch to setResult in the next couple of sprints tl.exit(code); }) .fail(function(err) { console.error(err.message); tl.debug('taskRunner fail'); tl.exit(1);
var tl = require('vso-task-lib'); var fs = require('fs'); tl.debug("Starting Replace Tokens step"); // get the task vars var filePath = tl.getPathInput("filePath", true, true); var tokenRegex = tl.getInput("tokenRegex", true); var files = tl.find(filePath); if (files.length === 1) { var file = files[0]; // read the file fs.readFile(file, 'utf8', function (err, data) { if (err) { tl.error("Could not read file " + filePath + ". Error is " + err.message); tl.exit(1); } var reg = new RegExp(tokenRegex, "g"); console.info("Starting regex replacement in " + file); // loop through each match var match; while ((match = reg.exec(data)) !== null) { // find the variable value in the environment var varName = match[1]; var varValue = tl.getVariable(varName); if (varValue === null) { tl.warning("... token " + varName + " does not have an environment value"); } else { data = data.replace(match[0], varValue); tl.debug("... replaced token " + varName); } }
.fail(function(err) { console.error(err.message); tl.debug('taskRunner fail'); tl.exit(1); })
var tl = require('vso-task-lib'); var sh = require('shelljs'); var fs = require('fs'); tl.debug("Starting Replace Tokens task"); // get the task vars var sourcePath = tl.getPathInput("sourcePath", true, true); var filePattern = tl.getInput("filePattern", true); var tokenRegex = tl.getInput("tokenRegex", true); var secretTokenInput = tl.getInput("secretTokens", false); // store the tokens and values if there is any secret token input var secretTokens = {}; if (typeof secretTokenInput !== "undefined") { var inputArray = secretTokenInput.split(";"); for (var _i = 0; _i < inputArray.length; _i++) { var token = inputArray[_i]; if (token.indexOf(":") > -1) { var valArray = token.split(":"); if (valArray.length == 2) { var key = valArray[0].trim().toLowerCase(); secretTokens[key] = valArray[1].trim(); console.log("Secret token input found [" + key + "]"); } } } tl.debug("secretTokens: found [" + Object.keys(secretTokens).length + "] tokens"); } tl.debug("sourcePath: [" + sourcePath + "]"); tl.debug("filePattern: [" + filePattern + "]"); tl.debug("tokenRegex: [" + tokenRegex + "]"); if (filePattern === undefined || filePattern.length === 0) { filePattern = "*.*";