diff --git a/tasks/config/downloadSelenium.js b/tasks/config/downloadSelenium.js index d69fa8d406276c..132f44fafb3943 100644 --- a/tasks/config/downloadSelenium.js +++ b/tasks/config/downloadSelenium.js @@ -1,14 +1,18 @@ var path = require('path'); +import { resolve as resolveUrl } from 'url'; +const URL = 'https://selenium-release.storage.googleapis.com/2.48/selenium-server-standalone-2.48.2.jar'; +const DIR = resolveUrl(URL, './'); +const FILE = URL.replace(DIR, ''); module.exports = function (grunt) { return { options: { selenium: { - filename: 'selenium-server-standalone-2.48.2.jar', - server: 'https://selenium-release.storage.googleapis.com/2.48/', + filename: FILE, + server: DIR, md5: 'b2784fc67c149d3c13c83d2108104689', - directory: path.join(grunt.config.get('root'), 'selenium') + path: path.join(grunt.config.get('root'), 'selenium', FILE) } } }; diff --git a/tasks/config/run.js b/tasks/config/run.js index 36f166b5477b5e..e98bfe894e7257 100644 --- a/tasks/config/run.js +++ b/tasks/config/run.js @@ -122,7 +122,7 @@ module.exports = function (grunt) { cmd: 'java', args: [ '-jar', - 'selenium/selenium-server-standalone-2.48.2.jar', + '<%= downloadSelenium.options.selenium.path %>', '-port', uiConfig.servers.webdriver.port, ] @@ -138,7 +138,7 @@ module.exports = function (grunt) { cmd: 'java', args: [ '-jar', - 'selenium/selenium-server-standalone-2.48.2.jar', + '<%= downloadSelenium.options.selenium.path %>', '-port', uiConfig.servers.webdriver.port, ] diff --git a/tasks/download_selenium.js b/tasks/download_selenium.js index 62840493ee2a8e..cdce3e0ade2116 100644 --- a/tasks/download_selenium.js +++ b/tasks/download_selenium.js @@ -11,8 +11,9 @@ module.exports = function (grunt) { const done = this.async(); const config = this.options(); - const SELENIUM_FILE_PATH = path.join(config.selenium.directory, config.selenium.filename); - const SELENIUM_DOWNLOAD_URL = config.selenium.server + config.selenium.filename; + const FILE = config.selenium.path; + const DIR = path.dirname(config.selenium.path); + const URL = config.selenium.server + config.selenium.filename; function validateDownload(path, expectedHash, success) { grunt.log.write('Validating hash...'); @@ -28,27 +29,27 @@ module.exports = function (grunt) { } function downloadSelenium(success) { - grunt.log.write(`Downloading ${SELENIUM_DOWNLOAD_URL}...`); - request.get(SELENIUM_DOWNLOAD_URL) - .pipe(fs.createWriteStream(SELENIUM_FILE_PATH)) + grunt.log.write(`Downloading ${URL}...`); + request.get(URL) + .pipe(fs.createWriteStream(FILE)) .on('error', function downloadError(err) { grunt.fail.warn(err); }) .on('finish', function downloadFinish() { grunt.log.writeln('done'); - validateDownload(SELENIUM_FILE_PATH, config.selenium.md5, success); + validateDownload(FILE, config.selenium.md5, success); }); } function start() { try { - fs.mkdirSync(config.selenium.directory); + fs.mkdirSync(DIR); } catch (err) { if (err && err.code !== 'EEXIST') grunt.fail.warn(err); } - if (fs.existsSync(SELENIUM_FILE_PATH)) { - validateDownload(SELENIUM_FILE_PATH, config.selenium.md5, done); + if (fs.existsSync(FILE)) { + validateDownload(FILE, config.selenium.md5, done); } else { downloadSelenium(done); } diff --git a/tasks/jenkins.js b/tasks/jenkins.js index b1601ff0fbb3d5..77a2673cffb7e7 100644 --- a/tasks/jenkins.js +++ b/tasks/jenkins.js @@ -1,7 +1,18 @@ +import { compact } from 'lodash'; +import { delimiter } from 'path'; + module.exports = function (grunt) { - let { compact } = require('lodash'); grunt.registerTask('jenkins', 'Jenkins build script', function () { - process.env.JAVA_HOME = '/usr/lib/jvm/jdk8'; + // make sure JAVA_HOME points to JDK8 + const HOME = '/usr/lib/jvm/jdk8'; + process.env.JAVA_HOME = HOME; + + // extend PATH to point to JDK8 + const path = process.env.PATH.split(delimiter); + path.unshift(`${HOME}/bin`); + process.env.PATH = path.join(delimiter); + + // always build os packages on jenkins grunt.option('os-packages', true); grunt.task.run(compact([