Merge pull request #6590 from spalger/upgrade/selenium

[jenkins] ensure that JDK8 is in path
This commit is contained in:
Spencer 2016-03-21 15:48:23 -07:00
commit 7f089c4a5f
4 changed files with 32 additions and 16 deletions

View file

@ -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)
}
}
};

View file

@ -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,
]

View file

@ -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);
}

View file

@ -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([